use strict; # I'm hinting that this should be part of the (error checking you took out) my @pids; while (1) { # Loop other processing here. push(@pids,load_file($this_file)); } reap_children(@pids); sub load_file() { my $childProcess; $childProcess = fork(); unless($childProcess) { # Child process so lets exec the loader. exec("loader $this_file"); exit 0; } return $childProcess; } sub reap_children() { foreach(@_) { wait($_); } }