Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Perl: How to delete an entry in hash

Perl: How to delete an entry in hash
{filelink=14706}

#!/usr/bin/perl -w
use strict;
# create an Hash
%myHash = ( "january"  => 31,
          	  "February"  => 28,
              "March" => 31,
              "April"  => 30,
              "May"  => undef );
 # get Hash items
foreach my $months (keys %myHash)
{
    print "$months=>$myHash{$months}n";
}
# remove specified entry
delete $myHash{"April"};
print "What about 'April'? $myHash{'April'}"; # error, this entry does not exist

Users who found this page were searching for:

  • perl delete hash entry
  • perl remove entry from hash
  • delete perl hash entry
  • perl how to remove a, entry from a hash
  • perl remove hash entry

No comments yet.

Leave a Comment