Ok, this still deals with that Perl class I'm taking, so be warned.  And
please don't laugh at my coding, I'm very new to Perl, so it's bound to look
pathetic to those of you who have been doing this longer.

My problem is this:

I'm taking the results from a hash search (that determines if a particular
student name and password combination is valid) and passing it to another
hash search (which is part of an if loop), which is supposed to print out
the assignments for the student.  That works with one small problem, it
reprints the students name under the line with the assignments.  The other
problem is that if I repeat the loop, it doubles the results, so I get two
identicle lines.

Here's my search code.  Any suggestions on what I'm doing wrong would be
greatly appreciated.

$nk is the password, $search is the student name searched out previously.

  while (@n = each %assignments) {
     if (grep /($nk)/, @n) {
  $keys[++$#keys] = $n[0];
     }
 }

 if (@keys) {
     print "Your assignments: \n";
     foreach $password (sort { $b cmp $a } @keys) {
  print "   $search, $assignments{$password}\n";
}
 } else {
     print "That password doesn't exist.\n";
 }


Thanks!

Jolinar

--

May you have warm words on a cold evening,
A full moon on a dark night,
And the road downhill all the way to your door.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to