Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: hash and array mismatch

by TGI (Parson)
on May 10, 2007 at 20:19 UTC ( #614755=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://614755]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2023-09-28 16:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?