http://qs321.pair.com?node_id=886533


in reply to parallelising processes

Have a look at Parallel::Iterator, too.

You can set the number of parallel workers with the option workers:

use strict; use warnings; # Number of parallel tasks my %options = (); $options{workers} = 8; # Execute tasks in parallel my @results = iterate_as_array( \%options, $worker, \@tasks );

Hth, Thomas

Replies are listed 'Best First'.
Re^2: parallelising processes
by hermida (Scribe) on Feb 06, 2011 at 21:29 UTC
    Also have a look at Parallel::Forker, I use it all the time it works great exactly as you expect and has advantages over Parallel::ForkManager like child process signalling.
    use Parallel::Forker; my $forker = Parallel::Forker->new(use_sig_child => 1, max_proc => 8); $SIG{CHLD} = sub { Parallel::Forker::sig_child($forker); }; $SIG{TERM} = sub { $forker->kill_tree_all('TERM') if $forker && $forke +r->in_parent; }; for (1..10) { $forker->schedule(run_on_start => sub { # do child process code here })->ready(); } # wait for all child processes to finish $forker->wait_all();
    hth
Re^2: parallelising processes
by RobertCraven (Sexton) on Apr 07, 2011 at 08:02 UTC
    Thank for your answer, unfortunately Parallel::Iterator is also not available in that environment.