Writing Portable DBM Programs with the AnyDBM Module : AnyDBM « Database « Perl






Writing Portable DBM Programs with the AnyDBM Module

   

#!/usr/bin/perl
use strict;
use warnings;
use AnyDBM_File;
use POSIX;
my %dbm;
my $db_file="anydbmdemo.dbm";
tie (%dbm, 'AnyDBM_File', $db_file, O_CREAT|O_RDWR, 0644);
unless (tied %dbm) {
    print "Error opening $db_file $!\n";
} else {
    $dbm{'Created'}=localtime;
    foreach (sort keys %dbm) {
        print "$_ => $dbm{$_}\n";
    }
    untie %dbm;
}

   
    
    
  








Related examples in the same category

1.Deleting Entries from a DBM File
2.Retrieving Data from a DBM File
3.Create, add, delete, and close a DBM file and how to create a Perl-style report.