in reply to Re: Keys() required to autovivify?
in thread Keys() required to autovivify?
My real code looked like:
by which I meant to execute the body of the if statement only if $h{x} (was a hash and) had at least one element. But instead I got a syntax error. I had to switch toif (%{$h{x}}) { ... }
which was more than I wanted to say.if (keys %{$h{x}}) { ... }
I was wondering why the use of keys() made perl smart enough to autovivify my hash, but the use of %{$h{x}} wasn't enough to cause it to autovivify (and then return a false value since the autovivified hash value was empty).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Keys() required to autovivify?
by shmem (Chancellor) on Dec 30, 2007 at 10:26 UTC | |
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 |