use strict; use warnings; use Parallel::ForkManager; my $fork_manager = Parallel::ForkManager -> new ( 32 ); my @p = split ("1,0.6,0.4,0.1,0.6,0,0.4,0.4,1,0.5,1,1,1"); my @param_arr = (); $fork_manager -> run_on_finish(sub { my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data_structure_reference) = @_; # retrieve data structure from child if (defined($data_structure_reference)) { # if children pass a string (they all should here, and it should be the $temp_out) my $out = ${$data_structure_reference}; # append string passed by child to array push @param_arr, $out; # append string passed by child to array } else { # issue warning if not having output as expected print "No message received from child process $pid!\n"; };} ); # my $fm_outer_1 = new Parallel::ForkManager -> new ( 6 ) # loop through desired combinations for ($p[0]=0; $p[0]<=1; $p[0]+=0.2){ for ($p[1]=0; $p[1]<=1; $p[1]+=0.2){ for ($p[2]=0; $p[2]<=1; $p[2]+=0.2){ for ($p[3]=0; $p[3]<=1; $p[3]+=0.2){ for ($p[4]=0; $p[4]<=1; $p[4]+=0.2){ for ($p[5]=0; $p[5]<=1; $p[5]+=0.2){ for ($p[6]=0; $p[6]<=1; $p[6]+=0.2){ for ($p[7]=0; $p[7]<=1; $p[7]+=0.2){ for ($p[8]=0; $p[8]<=1; $p[8]+=0.2){ for ($p[9]=0; $p[9]<=1; $p[9]+=0.2){ # $fm_outer_1 -> start and next; for ($p[10]=0; $p[10]<=1; $p[10]+=0.2){ $fork_manager -> start and next; $p[11]=1; $p[12]=1; #------------- $temp_out = "$p[0]\t$p[1]\t$p[2]\t$p[3]\t$p[4]\t$p[5]\t$p[6]\t$p[7]\t$p[8]\t$p[9]\t$p[10]\t$p[11]\t$p[12]\n"; #------------- $fork_manager -> finish(0, \$temp_out) # return $temp_out to parent }; # $fm_outer_1 -> finish() };};};};};};};};};}; $fork_manager -> wait_all_children(); $fm_outer_1 -> wait_all_children(); # fun with @param_arr..