# Store the contents of the first file into $hash{col1_col2} open (FILE1, $filename1) or die "Unable to open $filename1 because $!\n"; while ($line = ) { chomp ($line); ($chrX, $chrpos, $value1, $value2) = split (/\t/, $line); $key1 = join ("_", $chrX, $chrpos); $hash{$key1}++; }; close FILE1;