in reply to Re^2: Keys() required to autovivify?
in thread Keys() required to autovivify?
only if $h{x} (was a hash and) had at least one element
Then test whether the value of $h{x} actually is a hash reference.
If you say keys %{$h{x}} it is assumed you know what you are doing and want autovivifying, while dereferencing an undef value could just be a mistake. strict 'refs' catches that - that is what strict is about ;-)
By using keys you look inside the box (= the hashref), so perl autovivifies it, if it doesn't exist; by dereferencing you look at the box only.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Keys() required to autovivify?
by Anonymous Monk on Dec 30, 2007 at 14:12 UTC | |
by shmem (Chancellor) on Dec 30, 2007 at 19:03 UTC | |
by jrw (Monk) on Dec 30, 2007 at 23:39 UTC | |
by shmem (Chancellor) on Dec 31, 2007 at 12:43 UTC |