
October 17th, 2012, 12:21 PM
|
|
|
After playing with this for a while I think my problem is not understanding how ForkManager works. Within my loop, I thought the child executes everything between 'start and next' and 'finish'. In the meantime the parent continues executing everything after 'finish' to the end of the loop. Then the loop runs again creating a new child and the parent executes to the end of the loop again. Do I have this wrong? Here is my code:
Code:
foreach my $url (@urls) {
unless ($seen{$url}++) {
my $proc=process->new();
$proc->pid($pm->start and next);
chomp($url);
trim($url);
print "*************Processing $url*******************\n";
system("$helper_utils/collect_user_metrics.pl", "$url",">$tempoutput/collect_user_metrics.txt");
system("$helper_utils/get_docroot_info.pl", "$pool", "$url",">$tempoutput/get_docroot_info.txt");
$pm->finish();
print("Adding new child to array\n");
$proc->name($url);
push(@processed,$proc);
}
}
My debug print (adding new child) is never output. Can someone clear up how this works for me? TIA.
|