Steve Grazzini said:
You actually need
defined (my $pid = fork) or die "Cannot fork: $!";
exit if $pid;
Your version exits in the child as well...
Oops. Should have had:
(defined(fork() && exit)) or die "Cannot fork: $!\n";
for properly obscure, though correct, behavior.

I do tend to
forget that // returns the left side if it is defined, even if it is
false.
Actually, the correct translation of a//b is defined(a) ? a : b, so I
should have said
my $pid;
(defined($pid=fork()) ? $pid : die "Cannot fork: $!") && exit;
Here's another interesting way to approximate // behavior (in the
sense that the expressions look fairly similar):
${dref(fork()) || die "Cannot fork: $!"} && exit;
# Return a ref to the value, if it is defined.
sub dref {
(defined $_[0]) ? \$_[0] : undef;
}
But for something like
$a // $b // $c
you would need to be sure you returned references in each case:
${dref($a) || $dref($b) || \$c}