Check key existance after using 'delete' operator : delete « Hash « Perl






Check key existance after using 'delete' operator

    

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

delete($hash{'fruit'});

if (exists($hash{"fruit"})) {
    print "Key exists.";
} else {
    print "Key does not exist.";
}

   
    
    
    
  








Related examples in the same category

1.Delete the element with key 'Joe' from %hash
2.Delete from hash
3.Delete an entry in hash
4.The delete Function
5.The delete operator removes a key/value pair from an associative array.