1package AnyDBM_File; 2 3use 5.005_64; 4our @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA; 5 6my $mod; 7for $mod (@ISA) { 8 if (eval "require $mod") { 9 @ISA = ($mod); # if we leave @ISA alone, warnings abound 10 return 1; 11 } 12} 13 14die "No DBM package was successfully found or installed"; 15#return 0; 16 17=head1 NAME 18 19AnyDBM_File - provide framework for multiple DBMs 20 21NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations 22 23=head1 SYNOPSIS 24 25 use AnyDBM_File; 26 27=head1 DESCRIPTION 28 29This module is a "pure virtual base class"--it has nothing of its own. 30It's just there to inherit from one of the various DBM packages. It 31prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See 32L<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and 33finally ODBM. This way old programs that used to use NDBM via dbmopen() 34can still do so, but new ones can reorder @ISA: 35 36 BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) } 37 use AnyDBM_File; 38 39Having multiple DBM implementations makes it trivial to copy database formats: 40 41 use POSIX; use NDBM_File; use DB_File; 42 tie %newhash, 'DB_File', $new_filename, O_CREAT|O_RDWR; 43 tie %oldhash, 'NDBM_File', $old_filename, 1, 0; 44 %newhash = %oldhash; 45 46=head2 DBM Comparisons 47 48Here's a partial table of features the different packages offer: 49 50 odbm ndbm sdbm gdbm bsd-db 51 ---- ---- ---- ---- ------ 52 Linkage comes w/ perl yes yes yes yes yes 53 Src comes w/ perl no no yes no no 54 Comes w/ many unix os yes yes[0] no no no 55 Builds ok on !unix ? ? yes yes ? 56 Code Size ? ? small big big 57 Database Size ? ? small big? ok[1] 58 Speed ? ? slow ok fast 59 FTPable no no yes yes yes 60 Easy to build N/A N/A yes yes ok[2] 61 Size limits 1k 4k 1k[3] none none 62 Byte-order independent no no no no yes 63 Licensing restrictions ? ? no yes no 64 65 66=over 4 67 68=item [0] 69 70on mixed universe machines, may be in the bsd compat library, 71which is often shunned. 72 73=item [1] 74 75Can be trimmed if you compile for one access method. 76 77=item [2] 78 79See L<DB_File>. 80Requires symbolic links. 81 82=item [3] 83 84By default, but can be redefined. 85 86=back 87 88=head1 SEE ALSO 89 90dbm(3), ndbm(3), DB_File(3), L<perldbmfilter> 91 92=cut 93