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. }