in reply to Re: "print" of nonexistent element is actually altering a hash (updated)
in thread "print" of nonexistent element is actually altering a hash
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:
print 'yes' if exists $hash{www} && exists $hash{www}{xxx} && exists $hash{www}{xxx}{yyy} && exists $hash{www}{xxx}{yyy}{zzz};
Although as I described in a recent thread, I try to keep my hash accesses fairly simple.
In Section
Seekers of Perl Wisdom