in reply to Re^4: Hash slice again
in thread Hash slice again
Any nonexistent variable, or a variable containing undef, which we dereference while looking for a variable location(technically called an lvalue context), is automatically stuffed with appropriate reference to an empty item
That refers to
$ perl -le'print $r||"[undef]"; $r->{x}; print $r||"[undef]";' [undef] HASH(0x814ec28)
jethro was refering to a different kind of autovivification. Creating an alias (as undef does) to a non-existent array or hash element can create (vivify) the element in question (with value undef).
$ perl -le'sub f {} print 0+keys %h; for ($h{x}) {} print 0+keys %h;' 0 1
|
|---|