DATELOOP: while ( ($currentdate <= $enddate) && ($item < 5) ) { $item++; pipe *{$item},RETHAND; unless ($pid = fork()) { print "$command\n"; system($command); print RETHAND "Completed $currentdate\n"; exit(); } $currentdate = nextdate($currentdate); } foreach $item2 (@waitlist) { $response = <$item2>; # received from $item print "$response\n"; $item--; } if ($currentdate <= $enddate) {goto DATELOOP;}