Keep It Simple, Stupid | |
PerlMonks |
Re: How can I assign the elements in an array to only the key values in a hash?by MeowChow (Vicar) |
on Mar 31, 2001 at 06:19 UTC ( [id://68599]=note: print w/replies, xml ) | Need Help?? |
I prefer:
While this does exactly the same thing as the above, the syntax of @hash{@array} = undef is misleading, since only the first hash value is explictly set to undef, while the rest are implicitly undef'd. Novices who see this code might later write the following, expecting it to set all hash values to 1: Of course, only the first hash value is set to 1 in this case, and the rest become undef. MeowChow s aamecha.s a..a\u$&owag.print
In Section
Seekers of Perl Wisdom
|
|