my $pid = fork; if ($pid) { # Parent. } elsif (defined $pid) { # Child. # Don't forget to let it exit. } else { # Error. }