Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Is it possible to use key/values of a Hash/Hash ref while it's being initialized?by ikegami (Patriarch) |
on Sep 14, 2005 at 20:04 UTC ( [id://491997]=note: print w/replies, xml ) | Need Help?? |
Yes:
Admittedly, you have to change your initialization syntax somewhat. The reason is that list on the right hand side of the = is built before the assignment even starts. (See perlop for operator precedence.) Some people seem to think %h = (a=>b, c=>d); is a hash constructor/initializer, but it's not. It's simply a list which gets assigned to a hash.
In Section
Seekers of Perl Wisdom
|
|