##
use strict;
use warnings;
foreach (@ARGV) {
die "Fork failed: $!\n" unless defined (my $pid = fork);
exit &process($_) unless $pid;
}
1 until -1 == wait;
...
####
use strict;
use warnings;
my $max = 4;
my $c = 0;
foreach (@ARGV) {
wait unless ++$c <= $max;
die "Fork failed: $!\n" unless defined (my $pid = fork);
exit &process($_) unless $pid;
}
1 until -1 == wait;
...