in reply to How to better represent a complex data structure.
Do i have to make the array declarations before i take their reference or can i do that at the same time?
You do not need to declare (or even name) the arrays at all.
When you push or assign to a complex data structure the intermediate aggregates will be autovivified (Ie. created if they do not yet exist.):
my %main_file; push @{ $main_file{ USER }[ 1 ] }, 'fred'; push @{ $main_file{ TEST }[ 3 ] }, 'bill'; push @{ $main_file{ TRIM }[ 0 ] }, 'john'; pp \%main_file;; { TEST => [undef, undef, undef, ["bill"]], TRIM => [["john"]], USER => [undef, ["fred"]], }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to better represent a complex data structure.
by Amblikai (Scribe) on Jan 08, 2013 at 17:15 UTC |