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.
In reply to Re: Multidimentional array help
by punkish
in thread Multidimentional array help
by sasrs99
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |