frazzmata wrote:
I have a problem
I am trying to take lines in a text file that look like this. although
there are 500 more or so (and they have more realistic names)
25727 dude, some M MEX.AMER. DORM1
25797 dude, other M BLACK DORM2
29291 guy, random M BLACK DORM3
30249 fella, helluva M BLACK DORM4
31139A brother, notmy M CAUC DORM5
Which is essentially, a student Id, last, first, sex, race, etc…..
I am trying to use the following code to make the student id the key
and the whole line the value (including the student ID that I am using
as the key)
So, an example would look like this on paper
Key: Value:
$student{25727} = 25727 dude, some M MEX.AMER.
DORM1
And so on
This is the code I’ve tried…
my %longz;
while (<IFILE>) {
chomp;
($ya,$rest) = split(/^\s+/,$_);
$longz{$ya} = $rest;
You are splitting on whitespace that only matches at the beginning of
the line. You probably want something like:
my ( $ya ) = split;
$longz{ $ya } = $_;
}
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/