in reply to forks, how do that?

You've got several issues going on. First, if you're using fork on Windows, you're really using Perl threads behind the scenes. See perlfork. If you want to work with subprocesses on Windows, I recommend checking out Win32::Job. As mentined above, getting data back from a fork is harder than getting it back from a thread -- you probably need to use some sort of external file or pipe. See perlipc. If you're trying to do multiple child processes at the same time, you've got added complexity in handling returned data.

For managing multiple, forked processes in general, I've seen many recommendations for Parallel::ForkManager as a cleaner interface. There's also a tutorial on it: Introduction to Parallel::ForkManager. It looks like what you want can be boiled down to something like this (adapted from the docs for it):

use Parallel::ForkManager; $pm = new Parallel::ForkManager($MAX_PROCESSES); my @task_details = ( # data needed for each sub-process ); foreach my $task (@task_details) { $pm->start and next; # do the fork # do the sub process work using whatever details are in $task # write the results to a file somewhere, perhaps with a # pre-set name passed in $task $pm->finish; # do the exit in the child process } $pm->wait_all_children; # Continue in parent and read in the results

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.