What you are probably going to want is a hash of hashes, as long as you can count on the values for your top level of hash being unique, and especially if the values in the top level hash being something you will frequently use for lookups.

In a hash of hashes you'd load and access your data in a pattern similar to:

$person->{'caralo_l'}{'title'} = "Mrs"; $person->{'androno_j'}{'room'} = "317"; $person->{'paterman_s'}{'last'} = "Paterman"; $person->{'paterman_s'}{'email'} = "stv@net.net";

The main downside to an array of hashes is that it (the array) will have to be traversed to find specific entries in the hashes. Of course, the top-level hash in a hash of hashes will have to be traversed if the keys aren't being helpful.

Check out Randall Schwartz's 'Learning Perl Objects, References and Modules' if you haven't done so for it's very lucid discussions of references and data structures.


In reply to Re: Is this a reasonable data structure? by Art_XIV
in thread Is this a reasonable data structure? by Theo

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.