[EMAIL PROTECTED] wrote:
ok I'm pretty much a noob here, so you have to expect some level of
stupidity... ;-)
I got this script off a site and have spent several hours trying to
fix it yet I clearly still do not understand what exactly it is doing.
To me it appears to have problems when there is "nothing" in the hash
called %links?
Here is the code:
#!/usr/bin/perl -wT
use warnings;
use strict;
use LWP::Simple;
require HTML::Parser;
require HTML::LinkExtor;
$Domain = "mysite.com";
$URL = get("http://www.site.com");
mkdir "$Domain";
perldoc -q "What.s wrong with always quoting \"$vars\"?"
You should verify that mkdir worked correctly:
mkdir $Domain or die "Cannot mkdir '$Domain' $!";
$LinkExtor = HTML::LinkExtor->new(\&links);
$LinkExtor->parse($URL);
sub links
{
($tag, %links) = @_;
if ($tag = ("a href")) {
The tag name is "a", there is no tag named "a href".
print "$tag\n";
# if ($tag = "a href" && $links{href} =~ m/'$Domain'/) {
# if ($tag = "a href") {
$url = $links{href};
There is no 'href' tag so you are assigning undef to $url.
$file = $url;
$file =~ s/http:\/\/www\.//;
$file =~ s/http:\/\///g;
$file =~ tr/\//-/;
You get the warning message because $file contains undef. That would be
a bit neater with a delimiter other than /, for example:
$file =~ s!http://www\.!!;
$file =~ s!http://!!g;
$file =~ tr!/!-!;
mirror ($url, "$Domain/$file.html");
print "I'm Making $file.html\n";
}
}
$url = "http://$Domain";
$file = $url;
$file =~ s/http:\/\/www\.//;
$file =~ s/http:\/\///g;
$file =~ tr/\//-/;
mirror ($url, "$Domain/$file.html");
print "Making $file.html\n";
exit;
HERE is the ERROR:
./sitesucker.pl
Use of uninitialized value in pattern match (m//) at ./sitesucker.pl
line 19.
Use of uninitialized value in pattern match (m//) at ./sitesucker.pl
line 19.
Making mypcbusa.com.html
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/