my $downloader = eval { new Downloader() } or die($@);
print $downloader; ## This will be a different instance
my $thread1 = threads->new(
sub {
print $downloader; ### to this one
$downloader->fetch("http://www.webaddress.com", \%siteHash); ##
+<< This
## Will be a different hash to any similarly named hash above
## unless it was shared.
}
);
## Unless you are doing other stuff here,
## this is just an exspensive synchronous call :)
$thread1->join;
That would be better coded as
my %siteHash : shared;
my $thread = threads->new(
sub {
my( $address, $hashref ) = @_;
my $downloader = eval{ Downloader->new } or die $@;
$downloader->fetch( $address, $hashref );
},
$address, \%siteHash
) or die $!;
## do other stuff
$thread->join;
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|