in reply to Multidimentional array help
Multi-dimensional data structures are constructed using references (go look up references in Perl docs). An array (or a hash, for that matter, which is nothing but a special kind of array) can only contain scalars, and references are always scalars. So, you created references to arrays, and stick them in the parent array. Thus you achieve an array_of_arrays (aoh) or an array_of_hashes (aoh) or any variant thereof such as hoa, hoh, and so on.
So, how do you visualize this?
Well, look at your data .. A060,US,M10,WEDNESDAY,SEASONAL A061,US,M10,WEDNESDAY,SEASONAL A062,US,M10,WEDNESDAY,SEASONAL A063,US,M10,WEDNESDAY,SEASONAL A064,US,M10,WEDNESDAY,SEASONAL .. .. Put each line in a square bracket making it into an array reference .. [A060,US,M10,WEDNESDAY,SEASONAL] [A061,US,M10,WEDNESDAY,SEASONAL] [A062,US,M10,WEDNESDAY,SEASONAL] [A063,US,M10,WEDNESDAY,SEASONAL] [A064,US,M10,WEDNESDAY,SEASONAL] .. .. Now, separate each line with a comma, and put the entire block inside parens making it an array .. my @aoa = ( [A060,US,M10,WEDNESDAY,SEASONAL], [A061,US,M10,WEDNESDAY,SEASONAL], [A062,US,M10,WEDNESDAY,SEASONAL], [A063,US,M10,WEDNESDAY,SEASONAL], [A064,US,M10,WEDNESDAY,SEASONAL], );
done.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Multidimentional array help
by sasrs99 (Acolyte) on May 31, 2007 at 18:14 UTC | |
by punkish (Priest) on Jun 01, 2007 at 03:39 UTC |