programming-examples/perl/Hash/Check key existance after using 'delete' operator.pl

11 lines
208 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
$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.";
}