Syntactic Confectionery Delight | |
PerlMonks |
Re: keys %{$hash->{$href}} adds $href to the hash if it doesnt exist?by haukex (Archbishop) |
on Nov 17, 2017 at 09:42 UTC ( [id://1203651]=note: print w/replies, xml ) | Need Help?? |
This is "autovivification" and was just discussed the other day, see the replies in the thread Array dereference in foreach(), including the ones deeper down in the thread. Use exists to check if a hash key exists. As described in its documentation, if you have multi-level data structures (hashes of hashes), you need to check every level. Update: Discipulus just updated to show an example.
In Section
Seekers of Perl Wisdom
|
|