Create, add, delete, and close a DBM file and how to create a Perl-style report. : AnyDBM « Database « Perl






Create, add, delete, and close a DBM file and how to create a Perl-style report.

   

#!/usr/bin/perl

use AnyDBM_File;  
dbmopen(%states, "statedb", 0666[a]) || die;
TRY:  {
     print "State Abbreviation:";
     chomp($abbrev=<STDIN>);
     $abbrev = uc $abbrev;  
     print "Name of the state:";
     chomp($state=<STDIN>);
     lc $state;
     $states{$abbrev}="\u$state"; 
     print "Another entry? ";
     $answer = <STDIN>;
     redo TRY  if $answer =~ /Y|y/;
}
dbmclose(%states);

   
    
    
  








Related examples in the same category

1.Deleting Entries from a DBM File
2.Retrieving Data from a DBM File
3.Writing Portable DBM Programs with the AnyDBM Module