Mega Code Archive

 
Categories / Perl / Database
 

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);