$| = 1; use Time::HiRes qw(sleep); # allows sleep in fractions of seconds if(fork){ foreach my $i (1 .. 10) { print "I am the parent\n"; sleep 1; } print "parent exiting now.\n"; } else { foreach my $i (1 .. 30) { print "I am the child\n"; sleep 0.3; } print "Bye.\n"; }