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






Is a key defined in a hash

   

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

if (defined($hash{'vegetable'})) {
    print "Element is defined.";
} else {
    print "Element is not defined.";
}

   
    
    
  








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 in a hash
4.Is hash key defined and existed
5.Using variable as the key to get the value stored in a hash