in reply to Testing for key/value match

Are you sure that's the behaviour you want? If the hash contains the key but a different value you won't be "adding' your new key/value combination to the hash but overwriting the current value for that key in the hash. If you really wish to test as you suggest, just combine the tests you need.

if(exists($hash{$key}) && $hash{$key} eq $value) { # combo exists, add $key/$value to different hash } else { # combo doesn't exist, set it here possibly # overwriting previous value for same key. }