for my $file ( @data_files ) { $pm->fork and next; open my $h, "| ...." or die $!; print $h ...; ... $pm->finish; } $pm->wait;