in reply to Problem with while loop

Let's take one piece of your code and rewrite it a bit:
open (FILE, "$file") || die "Can't open $file"; $tmp=<FILE>; foreach(split(/\t/,$tmp)){ push(@hashkeys, $_); }
This takes only the first line of the file. I think what you want is:
my @hashkeys; open (FILE, "$file") || die "Can't open $file"; my @lines=<FILE>; foreach my $line (@lines){ my @fields = (split(/\t/,$line){ push(@hashkeys, $fields[0]); # or perhaps it's some ot +her # field you want? }
This isn't meant as a definitive answer but merely a small illustrative example to help you sort out exactly what you want to do