Perl: the Markov chain saw | |
PerlMonks |
Re^2: "print" of nonexistent element is actually altering a hashby haukex (Archbishop) |
on Feb 18, 2020 at 12:27 UTC ( [id://11113095]=note: print w/replies, xml ) | Need Help?? |
A very good point! Note also that in deeply nested hashes, exists will autovivify intermediate levels of the hash in the process of testing the existence of a low level element. To be nitpicky, it's not exists, but the hash accesses preceding the exists call. Anyway, I just wanted to point out that the ugly-but-entirely-core way to avoid the autovivification in this example is:
Although as I described in a recent thread, I try to keep my hash accesses fairly simple.
In Section
Seekers of Perl Wisdom
|
|