in reply to Autovivification identification
Perl knows what you want to do, because that is what you have asked it to do:
# You use push so you must want an array push @{ $provisions{$person} }, $1; # You use hash of hash addressing so you must want a hash $total_bytes{$source}{$destination} += $bytes;
The programmer has made the decision based on the data structure thought to be most useful in each case.
You can make it as crazy as you like and Perl will obey...
perl -MData::Dumper -le'$t{x}{y}[2]{foo}[3]{bar}=1; print Dumper \%t' $VAR1 = { 'x' => { 'y' => [ undef, undef, { 'foo' => [ undef, undef, undef, { 'bar' => 1 } ] } ] } };
Cheers,
R.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Autovivification identification
by choroba (Cardinal) on Aug 01, 2013 at 09:42 UTC | |
by Random_Walk (Prior) on Aug 02, 2013 at 08:14 UTC | |
|
Re^2: Autovivification identification
by gaurav (Sexton) on Aug 01, 2013 at 10:18 UTC | |
by ww (Archbishop) on Aug 01, 2013 at 10:41 UTC | |
by gaurav (Sexton) on Aug 01, 2013 at 12:37 UTC |