I think my brain disappeared temporarily.

I'm trying to figure out the best way to to organize my data so that I can produce output in a more flexible way.

For example, let's say that I have 3 pieces of data: Employee Number, Form Number, Date and I want to be able to produce a summary based on either the Employee Number or Form Number. E.g., For employee 1, list all the form numbers and when they were signed and, likewise, list the employees that have signed a particular form with date signed.

I know that I could stick everything in an sequential array and just offset by three until the third offset counter equals the size of the array but looking at the code is making me ill. Of course, this assumes that every set of data has exactly 3 elements, which is the case here (seems like a poor coding practice to me though).

Unfortunately, I've never really dealt with complex data structures so I'm a little at lost as to how to structure this data. A hash of arrays, hash of hashes, etc.

If that doesn't make sense here's some test data:

Employee Form Date 10001 10 20090101 10002 10 20080515 10003 10 20090323 10001 20 20090412 10002 20 20090711

I'm trying to make the output look something like this:

10001 10 20090101 20 20090412 10002 10 20080515 20 20090711 10003 10 20090323

Or

10 10001 20090101 10002 20090412 10003 20090323 20 10001 20090412 10002 20090711

Hopefully, that makes more sense than my word-based explanation.

Thanks


In reply to Data Structure Question by bohrme

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.