$x should not disappear outside the
scope of foo. my $x if undef; means that
$x is not local; the my, though
noted at compile time (mainly to prevent strict
complaints), does not actually produce a scoping effect
until run-time (if I understand the perldocs correctly).
Therefore, the my $x is never evaluated for
scoping purposes, since undef is always false.