programming-examples/perl/Hash/Delete from hash.pl

29 lines
457 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!C:/Perl/Bin
%animals = (H=> 'h', S=> 's', G=> 'g');
print "$animals{'S'} \n\n";
foreach $creature(keys %animals)
{
print "$creature \n";
}
print "\n\ndeleting...\n\n";
delete($animals{Shark});
foreach $creature(keys %animals)
{
print "$creature \n";
}
print "\n\n'emptying' the hash ...\n\n";
%animals=();
print "Displaying empty hash ...\n\n";
foreach $creature(keys %animals)
{
print "$creature \n";
}