Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
We don't bite newbies here... much
 
PerlMonks  

Re: (another) HoH question

by johngg (Abbot)
on Jun 23, 2012 at 18:24 UTC ( #977995=note: print w/ replies, xml ) Need Help??


in reply to (another) HoH question

A hash consists of key/value pairs, just one value per key. Your first statement assigns the value "4" to the key "tree". Your second statement replaces the value "4" with a reference to an anonymous sub-hash containing the key/value pair of "apple" and "6" and in the third statement you replace "6" with a sub-sub-hash containing "red" and "9" as key and value. At each stage you are replacing the previous value with reference to a new anonymous hash which is why your first-level values have disappeared. The fourth statement adds a second key/value pair of "fuji" and "4" to the sub-sub-hash.

I hope this explains where you are going wrong. Perhaps if you could describe what data structure you are trying to build we could give further advice. You will find the Data::Dumper module useful when trying to visualise the data structures you have created.

Cheers,

JohnGG


Comment on Re: (another) HoH question

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (16)
As of 2013-05-22 12:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (461 votes), past polls