in reply to hash values

You might be better of using the line count as the key, and line text as value...
#!/usr/bin/perl use strict; open IN, "$infile1" or die $!; my $linecount = 0; my %hash; while (my $line = <IN>) { chomp $line; $linecount+=1; $hash{$linecount} = $line; }