# checking if this key-value pair exists my ($key, $value) = ("foo", "123"); # ... in this hash my %hash = ( foo => "123", bar => "456", ); if (exists $hash{$key} and $hash{$key} eq $value) { print "key-value pair exists\n"; }