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