in reply to Re^3: Hashing it out: defined? exists?
in thread Hashing it out: defined? exists?

Thanks for the info. The exists documentation does warn that your first example of autovivification ($h{$i}{$j}) will autovivify even if you're checking with exists. That is,
{ my %h; 1 if exists $h{foo}{bar}; print("exists 2: ", (%h ? "auto-vivi" : "empty"), "\n"); }
prints "auto-vivi".

But for some reason I thought it was easier to autovivify keys.

Replies are listed 'Best First'.
Re^5: Hashing it out: defined? exists?
by ikegami (Patriarch) on Sep 02, 2005 at 20:25 UTC
    Keys are never auto-vivified. They are always created through assignment (incl the implicit assignment of an autovivified hash or array as shown in an earlier post).
    $h{$k} = $v; @h{$k} = ($v); %h = ($k, $v); # Also removes everything else.
    .