I am trying to speed up an existing script by focusing on a loop that runs through individual files and returns values to an array and several hashes. I think this can be done using forks, but I'm not sure how to return the data from the children to the parent.
Reading the documentation it says you can only return one data structure, and to keep it small. Is it possible to return all of the values I've listed in the pseudo code below?
If so(assuming it's going to involve making one data structure containing references to all of these, how would you go about that, and then how would you dereference it once it's back to the parent? (I have struggled immensely with referencing/dereferencing!)
#pseudo code use Parallel::ForkManager; $threads = 20 my $pfm = new Parallel::ForkManager( $threads ); FOREACH: foreach my $thing(keys %{$things_hr}) { my $pid = $pfm->start and next; #do stuff push @names, $name; #do stuff $thing{$name}{a} = $value1; $thing{$name}{b} = $value2; #do stuff $list{$id}{$name}{b} = $b; $list{$id}{$name}{e} = $b1; $list{$id}{$name}{a} = 0; $list{$id}{$name}{c} = $ar->[$id][3]; $list{$id}{$name}{i} = $ar->[$id][1]; $list{$id}{$name}{j} = $ar->[$id][2]; $list{$id}{$name}{k} = sprintf("%.4f",$ar->[$id][9]); $pfm->finish; $pfm->wait_all_children;
In reply to Parallel::ForkManager and multiple datasets by Speed_Freak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |