ok i did that. Can't see why value shouldn't be defined though :/
Can't call method "start" on an undefined value at line 18.
Can't call method "finish" on an undefined value at .\multithreadsTe\3
+.pl line 25.
</code
which basically are following lines in my code:
<code>
line 18: $pm->start and next LINKS;
line 25: $pm->finish;
my modified code again:
#!d:\perl\bin\perl.exe
use Parallel::ForkManager;
use LWP::Simple;
use Try::Tiny;
try{
my $pm = Parallel::ForkManager->new(6);}
catch {print "error 1 \n"; exit;};
LINKS:
for my $link ('http://us.a1.yimg.com/us.yimg.com/i/ww/m5v9.gif',
'http://hooboy.no-such-host.int/',
'http://www.yahoo.com',
'http://www.ora.com/ask_tim/graphics/asktim_header_main.gif',
'http://www.guardian.co.uk/',
'http://www.pixunlimited.co.uk/siteheaders/Guardian.gif') {
try {
$pm->start and next LINKS; }
catch { warn $_;
print "### ", $link, " \n error 2 \n"; next;};
try{
my ($content_type, $document_length, $modified_time, $expires, $
+server) = head($link);
print "$link fetched: declared lenght $document_length, \n"; }
catch{print "error 3 \n";};
try{$pm->finish; }
catch{ warn $_; print "error 4 \n";};
};
|