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