I have an interpretation for your results but no time for a formal proove.
At compiletime the pads for the lexicals $x and $y are associated to the sub. With a recursiv call perl has to allocate a new pad for the function, instead of reusing the old one.
Furthermore the if-branches are optimised away, so no "my $x" is executed at runtime to resetting $x to undef, so your accessing in 2 and 4 the last setting in the same level.
in short, it's one of these strange side effects of optimising code away, using B:Deparse you will most probably code-chunks missing.
you can also try this, which results in an error
(untested)goto label; if (0) { label: print "huhu"; }
so be aware of optimised code-chunks.
In reply to Re: Confusion over scope of "my" vars
by Anonymous Monk
in thread Confusion over scope of "my" vars
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |