in reply to Need advice on checking two hashes values and keys

You reuse the variable $key and I think it might be confusing things for you. The if in your foreach loop will always be true because $key comes from keys in %hash.

while (<$in1>) { chomp; my ($key1,$value1) = split (/\s*=\s*); if defined($hash{$key1}) { print "$key1 is in both!\n" } }
Dum Spiro Spero