http://www.perlmonks.org?node_id=1003944


in reply to Check if hash key value pair is defined

In a standard Perl hash, a key can only have one value. (Though that value could be a reference to an array.)

# 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"; }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'