MyaEsp has asked for the wisdom of the Perl Monks concerning the following question:
I am reading it in from the file, and using split, am extracting the first piece of data (the ID) to be the hash key, and the remainder to be the values. Here is the snippet:777666555 Smith Tom RM So 111222333 Jones Mary SD Fr 555444333 Johnson Lee IE Sr
However, I do not understand how to store the data from the entire file. It seems to me that this code would work only to read in one line. My problem arose when later, I am taking user input to determine if it matches a key...then, if so, outputting each piece of data corresponding to that key. How exactly would I obtain the Fname, Lname, and so on...in order to print?while(my $line2 = <INPUT>){ chomp($line2); my @splitStudent = split(' ', $line2); $size = @splitStudent; my $keys = splitStudent[0]; my $Lname = splitStudent[1]; my $Fname = splitStudent[2]; my $Major = splitStudent[3]; my $Year = splitStudent[4]; } my @IDSorted = sort(keys(%student));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hashes with multiple values?
by amarquis (Curate) on Mar 31, 2008 at 02:42 UTC | |
|
Re: Hashes with multiple values?
by jwkrahn (Abbot) on Mar 31, 2008 at 03:39 UTC | |
by Anonymous Monk on Mar 31, 2008 at 08:34 UTC | |
by jwkrahn (Abbot) on Mar 31, 2008 at 08:40 UTC | |
by Anonymous Monk on Mar 31, 2008 at 11:22 UTC | |
|
Re: Hashes with multiple values?
by McDarren (Abbot) on Mar 31, 2008 at 05:00 UTC | |
|
Re: Hashes with multiple values?
by Zen (Deacon) on Mar 31, 2008 at 14:30 UTC |