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.
|
|---|