Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: autovivication and referencing

by hdb (Prior)
on Nov 20, 2013 at 13:28 UTC ( #1063520=note: print w/ replies, xml ) Need Help??

in reply to autovivication and referencing

A very valuable tool is Data::Dumper that let's you inspect the contents of variables. In your case:

use Data::Dumper; print Dumper \%hash;

will show you that the two scenarios are not the same.

With Data::Dumper you can figure out most of these kind of questions.

Comment on Re: autovivication and referencing
Select or Download Code
Re^2: autovivication and referencing
by Amblikai (Beadle) on Nov 20, 2013 at 13:37 UTC
    Ah i use Dumper all the time, i just didn't think of it in this case! Thanks! So if i was to "hard code" this complex data structure. Would i have to write it the first way with a separate "other_hash" declaration? Or can i write it somehow similarly to the second way? (The first one is what i want).

      No, just say key2 => { ... }, ie use braces instead of parentheses.

      perldsc is your friend, look at HASHES OF HASHES.

        Of Course! Doh!

        Thanks so much!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-05-07 03:42 GMT
Find Nodes?
    Voting Booth?

    In my home, the TV remote control is ...

    Results (154 votes), past polls