#!/usr/bin/perl -w
$pid = fork();  

if ($pid == 0) {  
   print "In child.\n";  
   exit(0);  # Terminate child.
} elsif (! defined $pid) {  
   # Not defined: means an error.
} else {  
   # Parent process.

   sleep(5);  # Wait

   $status = waitpid($pid, 0);

   print "Child is dead with PID $status.\n";
}