in reply to Scope difference between compile-time and run-time ( if( my $x = ... ) {...} )

Interestingly, changing if to while (and adding a last before the closing curly brace) moves the second destruction to line 28 (the previous print, but I guess it just means the end of the loop.

I've read somewhere it's an unwanted consequence of the implementation of else which needs to access the variables from the if condition, so they need to live a bit longer. In that case, I'd expect continue to have the same effect, but it clearly doesn't work that way.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Scope difference between compile-time and run-time
by LanX (Saint) on Jun 01, 2021 at 19:40 UTC
    I didn't replicate it but the SO example was with for not if

    One might build test-cases by evaling code with all possible compounds.

    I suppose the effect is also visible in the OP-tree.

    I seem to remember we discussed it before, and that it's related to different phasing with the scope's scratch-pad where lexicals live.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery