use strict; # use warnings; use Parallel::ForkManager; use LWP::Simple; use IPC::Shareable; my $max_forks = 100; my $forkman = Parallel::ForkManager->new( $max_forks ); my $count=0; my %data; open (URLS, " 1 }; $SIG{INT} = sub { die "$$ dying\n" }; print "Parent PID is $$\n"; while( my $url = ) { $forkman->start and next; chomp($url); fetch($url); $forkman->finish; } $forkman->wait_all_children; close URLS; print "\n\nDONE.\n"; sub fetch { #html get to test parallel forks my $target = shift; $count_handle->shlock(); my $thiscount = $count++; $count_handle->shunlock(); my @header = head("http://$target"); print "PID: $$, $thiscount: $target - @header\n"; }