Just to expand on dragonchild's comment, I'd be inclined to create a package for each kind of account, with a "new" method to create a blessed object from the data in the original text file. Each $accounts{ssn} would contain an anonymous array of these objects. Creating %accounts might be done as follows:
while (<>) { my($ssn, $obj) = parse_account($_); push @{$accounts{$ssn}}, $obj; }
parse_account() of course would have to be able to determine the account type that the string defines, then call the appropriate account-object constructor. Each individual account-type package would provide a standard set of methods to access account information. E.g. to print out all the email addresses you'd implement a method called "email" within each package; it could be called like this:
while (my($ssn, $acctlist) = each %accounts) { foreach my $acct (@$acctlist) { print $ssn, $acct->email, "\n"; } }
A simple, individual "email" method would just look like:
sub email { my $self = shift; return $self->{'email'}; }
If you wanted to get fancy, all of the individual account-type packages could inherit from a more generic package; this would let you avoid having to create all these duplicate trivial methods.

In reply to Re: Balancing Complexities of Data Structures, Code and Readability by kjherron
in thread Balancing Complexities of Data Structures, Code and Readability by jlongino

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.