With the necessary <code> tags to interpret this post:
How can I read the following tabular information about students scores from an input file and represent it in a hash in a perl program and how would I make reference to a particular score using name and score as keys.
Name reg score1 score2 score3 score4 a 1 2 3 3 4 b 2 4 5 6 7 c 3 5 6 7 9 d 4 6 0 2 8 e 5 0 9 5 3
This certainly screams of homework, but it's a simple abstract question, even if it is probably covered in any first-semester Perl textbook. This can certainly be represented by a multi-dimensional array, but since you indicate you want to use a hash (a good idea), consider a hash of arrays or a hash of hashes.

Update: Since I think we're all of the agreement that this is homework, I've stripped out my code snippet that describes these solutions. Any small amount of research into complex Perl structures will yield you enough information to figure this out. You may also be interested in split.

See perlref and perllol and most any Perl book for information on complex data structures and references.


In reply to Re: Hashes1 by Fastolfe
in thread Hashes1 by Anonymous Monk

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.