Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^2: Autovivification with hash of hashesby Aristotle (Chancellor) |
on Jan 28, 2003 at 11:46 UTC ( [id://230553]=note: print w/replies, xml ) | Need Help?? |
This is broken. It will falsely return false for keys which exist but point to a value equal to 0 or the empty string. Nor does it solve the problem at hand, because exists $hashref->{KEY} will not autovivify that key into a hashref either. It is only when you try something like exists $hashref->{LEVEL1}->{LEVEL2} that the level one key is automagically created. But in that case, defined $hashref->{LEVEL1}->{LEVEL2} will do the same. So your "solution" adds a new problem without solving the existing one. Makeshifts last the longest.
In Section
Seekers of Perl Wisdom
|
|