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; } }