I am using Parallel::ForkManager to pass a few variables from the children to the parent. I’m able to pass $var…how do I pass more? (thanks again to Hobbs for helping me get this far)
use Parallel::ForkManager;
my $pm=new Parallel::ForkManager(10);
my(@cusips,@bad);
$pm->run_on_finish(sub{
my($pid,$exit_code,$ident,$exit_signal,$core_dump,$var,$v)=@_;
print "pid: ".$pid."\n";
print " first: ".${$var}."\n";
print " second: ".${$v}."\n";
});
for(1..3){
$pm->start and next; # do the fork
my $var=rand();
my $v=rand();
$pm->finish(0,\$var,\$v); # do the exit in the child process
}
$pm->wait_all_children;
There can be only one 🙂
Pass an array reference:
or a hash reference:
And:
or