Deleting Entries from a DBM File : AnyDBM « Database « Perl






Deleting Entries from a DBM File

   

#!/bin/perl
use AnyDBM_File;
dbmopen(%states, "statedb", 0666) || die;
TRY: {
     print "state abbreviation to remove. ";
     chomp($abbrev=<STDIN>);
     $abbrev = uc $abbrev;  
     delete $states{"$abbrev"};
     print "$abbrev removed.\n";
     print "Another entry? ";
     $answer = <STDIN>;
     redo TRY  if $answer =~ /Y|y/;  
}
dbmclose(%states);

   
    
    
  








Related examples in the same category

1.Retrieving Data from a DBM File
2.Writing Portable DBM Programs with the AnyDBM Module
3.Create, add, delete, and close a DBM file and how to create a Perl-style report.