package easydb; use strict; use DB_File; use Storable qw(freeze thaw) ; use Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = qw(&db_open &db_close &db_store &db_fetch &db_keys); @EXPORT_OK = qw(&db_open &db_close &db_store &db_fetch &db_keys); my %db ; sub db_open { my $dbfile = shift ; tie(%db, "DB_File", $dbfile) or die "Can't open $dbfile: $!"; return \%db ; } sub db_close { untie %db ; } sub db_store { my ($key, $hashref) = @_ ; $db{$key} = freeze($hashref); return $key; } sub db_fetch { my ($key) = shift; my $ref = thaw($db{$key}) ; return $ref ; } sub db_keys { return keys %db ; } 1;