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. | [reply] [d/l] [select] |
the first chapter of Elements of Programming with Perl outlines a lovely way of acco mplishing just this. good luck.
-- I'm a solipsist, and so is everyone else. (think about it)
| [reply] |