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

Re^3: create hash names dynamically

by cdarke (Prior)
on Jun 11, 2007 at 13:57 UTC ( [id://620494]=note: print w/replies, xml ) Need Help??


in reply to Re^2: create hash names dynamically
in thread create hash names dynamically

The others have explained it well (I had to nip out to get my car fixed - don't tell my boss).
The push adds a new element to an array, I guess you know about that.
The braces {} are called composers that create a hash and return a reference to it. In this case the hash is empty, but we could have placed a key=>value list(s) inside. So push is just putting a reference to the hash into the array.
The hashes do not have a name, they are (as others have said) anonymous. Which is great, because it means we don't have to stretch our imagination to think up umpteen hash names.
The memory for the hash will be freed up once the array itself is freed, or assigned to something else (there's a bit more to it, try searching for "Perl reference counting" if this concerns you).

Log In?
Username:
Password:

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

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

    No recent polls found