The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl

# Copyright 2004-2013, Paul Johnson (paul@pjcj.net)

# This software is free.  It is licensed under the same terms as Perl itself.

# The latest version of this software should be available from my homepage:
# http://www.pjcj.net

# __COVER__ skip_test $^O eq "MSWin32" || $] == 5.008007
# __COVER__ skip_reason Fork unreliable

$x = 1;

die unless defined ($pid = fork);

if ($pid)
{
    $x = 2;
    waitpid $pid, 0;
}
else
{
    $x = 3;
}

print "$x: $$\n";