<?xml version="1.0" encoding="windows-1252"?>
<node id="1003944" title="Re: Check if hash key value pair is defined" created="2012-11-15 02:13:53" updated="2012-11-15 02:13:53">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;In a standard Perl hash, a key can only have one value. (Though that value could be a reference to an array.)&lt;/p&gt;

&lt;code&gt;
# checking if this key-value pair exists
my ($key, $value) = ("foo", "123");

# ... in this hash
my %hash = (
  foo =&gt; "123",
  bar =&gt; "456",
);

if (exists $hash{$key} and $hash{$key} eq $value) {
  print "key-value pair exists\n";
}
&lt;/code&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1003939</field>
<field name="parent_node">
1003939</field>
</data>
</node>
