On Sep 5, 5:32 am, [EMAIL PROTECTED] (Hridyesh Pant) wrote: > in my case this works > while (<>) { > chomp; > my ($id, $record) = split(/\t+/,$_); > push @{$table{$id}}, $record; > } > > foreach $id (sort keys %table) { > print "$id "; > my @records = @{$table{$id}}; > print join ', ', sort @records; > print "\n"; > } > > --Hridyesh > > > > 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; > > } > > > My hope is to create a hash that I can use the student ids from > > another list, and if that id is present in the other list to print the > > value somewhere else. > > However, I have the comparison code down… I think. > > > My problem is the silly split on the $_ as it goes through the while > > loop… > > > Hope this makes sense.
> > > Keep in mind > > The machine I am doing this on is not online, and it is a windows > > machine. So I am using Activeperl with only the modules that come with > > it. > > > Help..- Hide quoted text - > > - Show quoted text - Ok, I tried this, it works. The only thing I need is: I need to be able to use the output for a lookup. in other words if ($id eq $hash{id}) { print OFILE "VALUE of $hash{key}; } or something to that effect so I can check and see if the ID # from one file is present in another and if so, add them to the output file. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/