|
|
| We don't bite newbies here... much | |
| PerlMonks |
Re: Difference in Hash Declarationby MidLifeXis (Prior) |
| on May 07, 2012 at 13:47 UTC ( #969262=note: print w/ replies, xml ) | Need Help?? |
|
The only one that is syntactically valid is the second one, however, I don't believe that it is doing what you are expecting. Since the parens denote precedence, what Perl reads it as is:
When assigning to hashes, later insertions with the same key end up replacing any earlier entries with the same key, leaving you with:
This can be shown with the use of Data::Dumper or the like. I think what you are intending is:
Data::Dumper (and any similar module) is a useful tool for visualizing nested data structures. --MidLifeXis
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||