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.
In reply to Re^2: Parallel::ForkManager loop in array
by marioroy
in thread Parallel::ForkManager loop in array
by steflama
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |