in reply to Re^3: Splitting an array into subarrays of size ~n
in thread Splitting an array into subarrays of size ~n
Good work. Two comments:
if(scalar(@directories)>=4){ @part= @directories[0..3]; } #Take as many as possible when <4 elements in the array elsif(scalar(@directories)<4){ @part = @directories [0..scalar(@directories)]; }
This is overkill, since you can reference non-existing array elements in perl without problems. So the following is equivalent:
@part= @directories[0..3];
The line
if ($pid == -1) {
should be
if (not $pid) {
because fork returns undef on failure, unlike the C library fork which returns -1
|
|---|