Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Parallel:ForkManager how to pass back a list

by marioroy (Prior)
on Apr 06, 2024 at 05:41 UTC ( [id://11158712]=note: print w/replies, xml ) Need Help??


in reply to Parallel:ForkManager how to pass back a list

The excitement of running parallel may cause us to forget, ah yes, simply let Perl be Perl. The P::FM documentation provides a scalar example. That is send a scalar ref, de-ref as such in the run_on_finish callback. Ditto for array or hash.

$pm->finish(0,\$scalar); # or $pm->finish(0,\@array); # or $pm->finish(0,\%hash);
$pm -> run_on_finish ( sub { my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data_ +ref) = @_; if (defined($data_ref)) { my $scalar = ${$data_ref}; # or my @array = @{$data_ref}; # or my %hash = %{$data_ref}; } } );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11158712]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2025-02-09 15:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (96 votes). Check out past polls.