Problem for the Perl meisters


Subject: Problem for the Perl meisters
From: stephen king (sking@chartercollege.edu)
Date: Thu Jun 06 2002 - 23:21:37 AKDT


Writing a script for ActiveState's ActivePerl 5.6.1 which (if the darn thing
worked) would do the same thing on a Windows box (with Perl installed, of
course) that wget does on a Linux box.

What I have (HTML comments added just in case anyone is reading w/ a
browser):
<!--
use LWP::Simple;
require HTML::Parser;

print "this is one\n";

require HTML::LinkExtor;

print "this is two\n";

$html = get("http://www.chartercollege.edu/king/index.htm");

print "this is three\n";

$link_extor = HTML::LinkExtor->new(\&handle_links);

print "this is four\n";

sub handle_links
{
  print "this is five\n";
  ($tag, %links) = @_;
  if ($tag = 'a href' && $links{href} ne '')
  {
    $url = $links{href};
    $file = test;
    $file =~ s/http:\/\/www\.//;
    $file =~ s/http:\/\///g;
    $file =~ tr/\//-/;
    print "Creating $file.\n";

    mirror ($url, $file);
  }
  else
  {
    print "no options\n"
  }
}
print "this is the end";
-->

Output I get is:
this is one
this is two
this is three
this is four
this is the end

Obviously, the sub is not evaluated. Anybody got any idea how come?
According to Active...'s web docs the syntax of the calling line (starting
with $link_extor = ) is OK; the second parameter is optional.

By the way...the URL is my own instructor web page. I KNOW it is there....

Thanks,
Stephen

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Thu Jun 06 2002 - 23:21:20 AKDT