#!/usr/bin/perl -w use strict; #this code is for WinXP, not Unix $| =1; #buffering is off! print "my Parent ID at start is: $$\n"; my $pid = fork(); if (!defined($pid)) { die "Couldn't fork"; } if ($pid == 0) #I am a child ## { print "My child PID =$$\n"; my $c =0; while ($c<10) { print $c++; sleep(1); } print "\n"; } else # I am parent ## { print "Parent PID = $$\n"; } print "end of PID = $$ process ID\n"; __END__ PRINTS: my Parent ID at start is: 3640 Parent PID = 3640 end of PID = 3640 process ID My child PID =-1628 0123456789 (one digit per second) end of PID = -1628 process ID