Is a key in a hash : key « Hash « Perl






Is a key in a hash

   


$hash{fruit} = apple;
$hash{sandwich} = hamburger;
$hash{drink} = bubbly;

if (exists($hash{'vegetable'})) {
    print "Key is in the hash.";
} else {
    print "Key is not in the hash.";
}

   
    
    
  








Related examples in the same category

1.Determine if the value for the key is defined
2.Hash Key and Value Retrieval
3.Is a key defined in a hash
4.Is hash key defined and existed
5.Using variable as the key to get the value stored in a hash