Store hashes in a DBM file: : DBM « Database « Perl






Store hashes in a DBM file:

   

#!/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'}) };

   
    
    
  








Related examples in the same category

1.Creating and Assigning Data to a DBM File
2.Open DBM up for read write access
3.Opening an MLDBM database is similar to opening a regular DBM database:
4.Reads DBM file, printing entries with tie and untie function
5.Using DBM databases with reports
6.Write out data into a DBM database
7.Copying from One DBM Format to Another