Quando provo a lanciare questo script :
codice:
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
use HTML::TokeParser;
use URI::Escape;
my $artist = $ARGV[0];
my $search = uri_escape($artist);
my $content = get('http://www.google.it/search?hl=it&c2coff=1&q='."$search".'&btnG=Cerca&meta=');
my $stream = new HTML::TokeParser(\$content);
while (my $tag = $stream->get_tag("a")) {
# Is there a 'class' attribute? Is it 'cf'?
if ($tag->[1]{class} and $tag->[1]{class} eq "cf") {
my $result = $stream->get_trimmed_text("/a");
$result =~ s/^.//g;
next if $result =~ /$artist/i;
print " - $result\n";
}
}
mi risponde con questo errore:
Use of uninitialized value in substr at C:/Perl/site/lib/HTML/PullParser.pm line
82.
Use of uninitialized value in length at C:/Perl/site/lib/HTML/PullParser.pm line
85.
la cosa strana è che se sostituisco
my $content = get('http://www.google.it/search?hl=it&c2coff=1&q='."$search".'&btnG=Cerca&m eta=');
con
my $content = get('http://www.google.it');
lo script funziona. quale può essere il problema?