in reply to Reading from filehandles in a loop and matching lines

Add use warnings; to the top of your code, then eliminate the warning messages you get (see use strict and warnings).

I wonder if your input file really has spaces instead of tab characters. Add these lines after your split line for debugging purposes:

print "n=$name\n"; print "d=$department\n"; print "s=$salary\n";

It would have helped us if you showed the command line you used to run your code. For example, I tried this, and it seemed to work:

$ 838601.pl HR Jack Stevens

See also: How do I compose an effective node title?