Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: 'local' for imported variables doesn't work as expected

by LanX (Saint)
on Oct 04, 2024 at 22:10 UTC ( [id://11162067]=note: print w/replies, xml ) Need Help??


in reply to Re: 'local' for imported variables doesn't work as expected (4 updates)
in thread 'local' for imported variables doesn't work as expected

> maybe local for hash values was implemented later than local for variables

Back in the days when I first learned that local also works for hash elements, I was very surprised. (How random! Why? ¹)

But now that I realize that every local is actually operating on hash elements, this finally makes a lot of sense. :)

(stash= symbol table hash, and a typeglob is very similar to a hash, just with a fixed number of slots)

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

Updates

¹) And most confusingly, why does it suddenly work for lexical hashes too???

DB<2> my %h=(a=>1); { local $h{a}=2; say %h}; say %h a2 a1

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2026-03-16 05:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.