in reply to Re^3: hash and array mismatch
in thread hash and array mismatch

I knew that autovivification would let you do things like $foo{a}{b}{c} = 7; I just didn't know that it worked for push and friends as well. Which is funny, because in perlreftut, it discusses the push related aspect.

I know I read perlreftut a few years ago. I guess this tidbit failed to stick.

For reference purposes, you can also do:

my ($foo, $bar, $baz); $foo->[1] = 92; # $foo = [92] print $bar->[0]; # $bar = []; print @{ $baz }; # DIES - $baz not in lvalue context, no autoviv.

Thanks for the pointer to autovivification. I obviously didn't understand it properly when I was first learning, and never really came back to the subject. Methinks I need to carefully reread Chapter 8 of Programming Perl.


TGI says moo