Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Check if hash key value pair is defined

by tobyink (Abbot)
on Nov 15, 2012 at 07:13 UTC ( #1003944=note: print w/replies, xml ) Need Help??


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'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003944]
help
Chatterbox?
[choroba]: yay!
[Corion]: Ooh, yes, yay ;-D
[Discipulus]: my backpack is ready for two nights in the mountains!
[Corion]: Discipulus: In the mountains during winter?
[choroba]: SHAttered

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2017-02-24 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (353 votes). Check out past polls.