#!/usr/bin/env perl -w $| = 1; @array = qw(one two three four five); $num = "10"; for ( 1 .. $num ) { my $pid = fork(); if ($pid) { # parent push( @childs, $pid ); } elsif ( $pid == 0 ) { # child print "@array\n\n"; sleep 3; exit(0); } else { die "couldn’t fork: $!\n"; } print "BEFORE FOR BRACKET\n"; } print "AFTER FOR BRACKET\n"; foreach (@childs) { waitpid( $_, 0 ); } exit(0); __END__