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" } }
In reply to Re: Need advice on checking two hashes values and keys
by GotToBTru
in thread Need advice on checking two hashes values and keys
by perlynewby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |