in reply to Splitting an array into subarrays of size ~n
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Splitting an array into subarrays of size ~n
by hotel (Beadle) on Mar 21, 2011 at 15:41 UTC | |
by hotel (Beadle) on Mar 21, 2011 at 16:06 UTC | |
by jethro (Monsignor) on Mar 21, 2011 at 17:16 UTC |