programming-examples/perl/Database/Retrieving Data from a DBM File.pl

27 lines
471 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/bin/perl
use AnyDBM_File;
dbmopen(%states, "statedb", 0666);
@sortedkeys=sort keys %states;
foreach $key ( @sortedkeys ){
$value=$states{$key};
$total++;
write;
}
dbmclose(%states);
format STDOUT_TOP=
Abbreviation State
------------------------------
.
format STDOUT=
@<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<
$key, $value
.
format SUMMARY=
------------------------------
Number of states:@###
$total
.
$~=SUMMARY;
write;