I did not mean to imply that exists causes autovivification. What I was trying to get at is that autovivification has made me wary of keys that exist spuriously. These can occur in a number of ways, and I'd rather avoid the issue altogether by using defined instead of exists as a matter of policy.
The point is not whether spurious autovivification can be avoided (it is not hard to do so). The point is that I want to write my code so that, if I find myself debugging it weeks or months later, I don't have to worry over every exists expression that I run across. In other words, the possibility of unintended autovivification renders exists suspect in my eyes, and I'd rather deal with such suspicions as little as possible. A consequence of this is that I don't use undef as a hash value unless it is really necessary, or in very narrowly circumscribed blocks of code, in which one can tell at a glance that unintended autovivification is not a problem. It's all defensive programming, like avoiding globals, for example.
the lowliest monk
In reply to Re^3: need explanation of @foo{@bar} = (); (hash slice)
by tlm
in thread need explanation of @foo{@bar} = (); (hash slice)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |