programming-examples/perl/Database/Store hashes in a DBM file.pl
2019-11-15 12:59:38 +01:00

15 lines
340 B
Perl

#!/usr/bin/perl
use warnings;
use strict;
use POSIX;
use SDBM_File;
use Storable;
my %dbm;
my $db_file="demo.dbm";
tie %dbm, 'SDBM_File', $db_file, O_CREAT|O_RDWR, 0644;
$dbm{'key'}=Storable::freeze({Name=>"John", Value=>"Smith", Age=>"42"});
my $href=Storable::thaw($dbm{'key'});
my %hash=%{ Storable::thaw($dbm{'key'}) };