open TWO, '<', $FILE2; # better be explicit ;-) while () { chomp; # correct indent level is here. my ($key,$value) = split /\s+/,$_; print "$key NOT IN FILE 1\n" unless $hash1{$key}; $hash2{$key} = $value; } #### foreach my $key (keys %hash1) { if(exists($hash2{$key}) { if($hash1{$key} == $hash2{$key}) # '==' if numeric, 'eq' if string { ... } else { ... } } else # this is the case you missed - $key not in file2 { ... } }