use strict; use MLDBM qw(DB_File); use DB_File; use Data::Dumper (); use Fcntl qw(O_RDWR O_CREAT); my $r = shift; $r->send_http_header("text/plain"); my $rh = { bar => ['a'..'c'], tar => { map {$_ => $_**2 } 1..4 }, }; my $dbfile = "/tmp/foo.db"; tie my %dbm, 'MLDBM', $dbfile, O_RDWR|O_CREAT, 0600, $DB_HASH or die $!; # assign a reference to a Perl datastructure $dbm{foo} = $rh; untie %dbm; # read the assigned value tie %dbm, 'MLDBM', $dbfile, O_RDWR|O_CREAT, 0600, $DB_HASH or die $!; my $foo = exists $dbm{foo} ? $dbm{foo} : 'undefined'; untie %dbm; print Data::Dumper::Dumper($foo);