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