in reply to assign variable and shift array
use strict; use warnings; print "Begin Main\n"; ## we store the child process in this array my @childArray; ## path to the files go in this array. It could be one or a dozen ## and is determined by another process our @fileArray = qw(fileone.txt filetwo.txt filethree.txt); ## This is the number of forks we will allow my $forkCeiling = "5"; my $pid; my $fileName; for ( my $forkCount = 1; $forkCount <= $forkCeiling; $forkCount++) { my $arrayIterator = $forkCount-1; $pid = fork(); if ($pid) { push(@childArray, $pid); } elsif ($pid == 0) { # call the download subroutine and pass the number of ++forks, parent pid and array print "Sending fork number $forkCount to the \"process + files\" subroutine...\n"; print $arrayIterator."\n"; my $file = $fileArray[$arrayIterator]; if(defined $file) { print "DEBUG: $file \n"; #procFiles($forkCount, $$, $file); } exit 0; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: assign variable and shift array
by ikegami (Patriarch) on May 06, 2011 at 20:59 UTC | |
|
Re^2: assign variable and shift array
by AK7033 (Initiate) on May 06, 2011 at 20:44 UTC |