in reply to Parallel::ForkManager loop in array

> I'm all out of ideas

Have you read the documentation of Parallel::ForkManager? Can you share the code that didn't work?

Update: Copied from the documentation, fruits, sleep, and srand added by me:

#!/usr/bin/perl use warnings; use strict; use Parallel::ForkManager; my $pm = Parallel::ForkManager->new(5); for my $fruit (qw( apple banana cherry lemon lime orange peach pear plum raspberry strawberry )) { my $pid = $pm->start and next; print "Sleeping with $fruit\n"; srand; # To prevent all the children from having the same seed. sleep 3 + rand 8; print "$fruit done.\n"; $pm->finish } $pm->wait_all_children;

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Parallel::ForkManager loop in array
by marioroy (Prior) on Oct 10, 2016 at 20:03 UTC

    In the spirit of TIMTOWDI, the following snippet demonstrates another way. Calling srand is not necessary as the seed is already unique per worker.

    #!/usr/bin/perl use warnings; use strict; use MCE::Loop chunk_size => 1, max_workers => 5; my @fruits = qw( apple banana cherry lemon lime orange peach pear plum raspberry strawberry ); mce_loop { my $fruit = $_; print "Sleeping with $fruit\n"; sleep 3 + rand 8; print "$fruit done.\n"; } \@fruits; MCE::Loop->finish;

    Regards, Mario.