in reply to Figuring out some data structure
What's happening is "autovivification" of an array reference.
A quote from the book:
Programming Perl, 3rd Ed., p.251
Chapter 8: References
"Implicit Creation of References"
References of an appropriate type simply spring into existence if you dereference them in an lvalue context that assumes they exist.
So your statement:
is the same as:push @{$labels{$tablename}}, $_;
See also autovivification in the glossary, and perlref.$labels{$tablename} = [] if !exists $labels{$tablename}; push @{$labels{$tablename}}, $_;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Figuring out some data structure
by ikegami (Patriarch) on Nov 01, 2009 at 18:29 UTC | |
by gmargo (Hermit) on Nov 01, 2009 at 20:32 UTC |