I liked stevieb's post. Here is something else to consider:
#!/usr/bin/perl -w use strict; ## An Array of Hash is the most similar Perl ## way of representing a 'C' array of structure my @classAoH = ( { name => 'Bob', grade => 'C', }, { name => 'Jane', grade => 'A', } ); ## An Array of Array can represent the same ## data, but we have to use an index number instead ## of a hash key to access the data my @classAoA = ( [ 'Bob' , 'C'], [ 'Jane', 'A'], ); foreach my $hash_reference (@classAoH) { print "$hash_reference->{name} $hash_reference->{grade} \n"; } foreach my $array_reference (@classAoA) { print "$array_reference->[0] $array_reference->[1]\n"; } __END__ Both foreach() loops print exactly same thing: Bob C Jane A The order is guaranteed because both are arrays of "something". The difference is that often {name} or {grade} means something more and is easier to understand in the rest of the code for the reader than [0] or [1]. So, "readability" is something to consider. Of course this is not "free". The AoH is less efficient than the AoA, but often that does not matter. Often the most important thing is understandability and maintainability and the AoH wins on that point.

In reply to Re: Array of array vs hash by Marshall
in thread Array of array vs hash by rakheek

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.