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