in reply to Exists and autovivification (was: Looping through a hash reference...)
in thread Looping through a hash reference is creating a key...?

Code such as
$bazref = \$foo{bar}{baz}
too relies on autovivification.
  • Comment on Re: Exists and autovivification (was: Looping through a hash reference...)
  • Download Code

Replies are listed 'Best First'.
Re^2: Exists and autovivification (was: Looping through a hash reference...)
by Roy Johnson (Monsignor) on Jun 13, 2004 at 20:38 UTC
    Good point. Taking a reference of anything would have to autovivify it.

    We're not really tightening our belts, it just feels that way because we're getting fatter.
Re^2: Exists and autovivification (\lvalue)
by tye (Sage) on Jun 24, 2004 at 19:44 UTC

    Taking a reference is an "lvalue context". So this isn't an exception but part of the same rule. Even in C, you can't take the address of a non-lvalue (it might be 'const' aka 'read-only', of course).

    The $hash{key1}{key2} autovification of 'key1' has long been considered a minor bug. So I'd hope that backward compatability to bugs isn't a good reason to a prevent fixing them.

    - tye