http://qs1969.pair.com?node_id=1072144

Jim has asked for the wisdom of the Perl Monks concerning the following question:

I want to use Perl 5.14 (ActiveState ActivePerl) to manage many thousands of executions of an external command-line utility under Microsoft Windows, each with a different argument. If I run them in sequence in a simple loop, they'll take too long to finish, so I want to run them in parallel as well as in an ordered sequence, n at a time (where the optimum value of n is probably going to be 20). I've never done this kind of job control before using Perl, so I need help getting started. Before now, I've used both tricks with the start command in funky systems of batch files and the nifty Unix xargs utility under both the MKS Toolkit and Cygwin. Now, for several important reasons, I need to use Perl instead.

So let's say I want to run a command-line utility named doit.exe 10,000 times on the arguments toit0000, toit0001, toit0002, …, toit9999. I want to invoke the jobs generally in that order, but I want to run them in parallel, 20 at a time. How do I do this in Perl? Assume I have a simple array of the ordered arguments; for example:  my @ordered_arguments = <DATA>; chomp @ordered_arguments;.

Jim