for ( my $count = 1; $count <= 10; $count++) { my $pid; if ($pid=fork) { } else { exec(&sub1($count, $lines,\@cnArray)); exit; # Ends the child process. } } while (wait() != -1) { }