If you just want working code, I have the perfect solution for you: Parallel::ForkManager. Perfect fit, so to speak
if you want to know more about fork and wait, just use "perldoc -f fork", "perldoc -f wait", "perldoc -f waitpid" and "perldoc perlipc". Or read the corresponding man pages of the underlying C library.
Basically you should be able to do up to 4 forks, then just wait until you wait()ed an equal number of times (or better until wait() returns -1). Getting the first 4 entries of an array is easy, just use my @part= splice(@array,0,4). How much you really get out of the array (because it may have only 1, 2 or 3 entries left) you will find out with scalar(@part)
In reply to Re: Splitting an array into subarrays of size ~n
by jethro
in thread Splitting an array into subarrays of size ~n
by hotel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |