Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Scope difference between compile-time and run-time

by choroba (Cardinal)
on Jun 01, 2021 at 19:29 UTC ( [id://11133383]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11133383]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2025-07-15 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.