Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Referencing localized variables, and typeglobs

by Laurent_R (Canon)
on Aug 30, 2017 at 21:38 UTC ( [id://1198360]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Referencing localized variables, and typeglobs
in thread Referencing localized variables, and typeglobs

One might expect that after the effects of the local are over, $x and $y could refer back to the original %h,
Why should it? $x and $y are assigned to the value returned by the do block. And this value happens to be an anonymous hash ref produced within the block. And $x does not know anything about the %h hash. The fact that %h is restored to an empty hash immediately thereafter is irrelevant to the value acquired by $x at the time of the assignment.

Well, I understand your concern, but I do not think there is any reason to worry here. I think the behavior is quite clear.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-19 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found