誰かが私のループが機能しない理由を説明できますか?
#!/usr/bin/perl -w
use warnings;
use strict;
use URI;
use Web::Scraper;
my $url = "http://example.com";
# prepare data
my $scrapedata = scraper {
process "div.something", 'pages[]' => '@rel';
};
# scrape the data
my $res = $scrapedata->scrape(URI->new($url));
# Get number of pages and define as var
for my $j (0 .. $#{$res->{pages}}) {
my $varpages = $res->{pages}[$j];
print "$varpages\n";
}
for ( my $count = 2; $count <= $varpages; $count++) {
print "$varpages\n";
print "$count\n";
}
これはエラーです:
# perl oli
Global symbol "$varpages" requires explicit package name at oli line 25.
Global symbol "$varpages" requires explicit package name at oli line 27.
Execution of oli aborted due to compilation errors.