in reply to Testing for key/value match

Here is one way.
my $new_key = 'NEW'; my $new_value = 'Value'; if (exists $file_hash{$new_key} && $file_hash{$new_key} eq $new_value) { # add to another hash, per the comment in your post } else { $file_hash{$new_key} = $new_value; }
We are testing whether it exists or not to catch the case when $new_value is undefined and $new_key does not exist in the hash. If the $new_value == undef, then no matter what the key is (if it doesn't exist) a true value will be returned because the key in the hash HAS a value of undef.