in reply to Confusion over scope of "my" vars
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Confusion over scope of "my" vars
by LanX (Saint) on Nov 26, 2008 at 18:20 UTC | |
by JavaFan (Canon) on Nov 26, 2008 at 18:24 UTC | |
by LanX (Saint) on Nov 26, 2008 at 18:31 UTC | |
by ikegami (Patriarch) on Nov 26, 2008 at 21:00 UTC | |
by LanX (Saint) on Nov 26, 2008 at 21:14 UTC | |
|