Commit | Line | Data |
a0d0e21e |
1 | package AnyDBM_File; |
2 | |
3 | @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA; |
4 | |
5 | eval { require NDBM_File } || |
6 | eval { require DB_File } || |
7 | eval { require GDBM_File } || |
8 | eval { require SDBM_File } || |
9 | eval { require ODBM_File }; |
f06db76b |
10 | |
11 | =head1 NAME |
12 | |
13 | AnyDBM_File - provide framework for multiple DBMs |
14 | |
15 | NDBM_File, ODBM_File, SDBM_File, GDBM_File - various DBM implementations |
16 | |
17 | =head1 SYNOPSIS |
18 | |
19 | use AnyDBM_File; |
20 | |
21 | =head1 DESCRIPTION |
22 | |
23 | This module is a "pure virtual base class"--it has nothing of its own. |
24 | It's just there to inherit from one of the various DBM packages. It |
25 | prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See |
26 | L<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and |
27 | finally ODBM. This way old programs that used to use NDBM via dbmopen() |
28 | can still do so, but new ones can reorder @ISA: |
29 | |
30 | @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File); |
31 | |
32 | Note, however, that an explicit use overrides the specified order: |
33 | |
34 | use GDBM_File; |
35 | @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File); |
36 | |
37 | will only find GDBM_File. |
38 | |
39 | Having 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 | |
48 | Here'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 | |
70 | on mixed universe machines, may be in the bsd compat library, |
71 | which is often shunned. |
72 | |
73 | =item [1] |
74 | |
75 | Can be trimmed if you compile for one access method. |
76 | |
77 | =item [2] |
78 | |
79 | See L<DB_File>. |
80 | Requires symbolic links. |
81 | |
82 | =item [3] |
83 | |
84 | By default, but can be redefined. |
85 | |
86 | =back |
87 | |
88 | =head1 SEE ALSO |
89 | |
90 | dbm(3), ndbm(3), DB_File(3) |
91 | |
92 | =cut |