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