1AnyDBM_File(3pm) Perl Programmers Reference Guide AnyDBM_File(3pm)
2
3
4
6 AnyDBM_File - provide framework for multiple DBMs
7
8 NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM
9 implementations
10
12 use AnyDBM_File;
13
15 This module is a "pure virtual base class"--it has nothing of its own.
16 It's just there to inherit from one of the various DBM packages. It
17 prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB
18 (See DB_File), GDBM, SDBM (which is always there--it comes with Perl),
19 and finally ODBM. This way old programs that used to use NDBM via
20 dbmopen() can still do so, but new ones can reorder @ISA:
21
22 BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
23 use AnyDBM_File;
24
25 Having multiple DBM implementations makes it trivial to copy database
26 formats:
27
28 use POSIX; use NDBM_File; use DB_File;
29 tie %newhash, 'DB_File', $new_filename, O_CREATâȘO_RDWR;
30 tie %oldhash, 'NDBM_File', $old_filename, 1, 0;
31 %newhash = %oldhash;
32
33 DBM Comparisons
34
35 Here's a partial table of features the different packages offer:
36
37 odbm ndbm sdbm gdbm bsd-db
38 ---- ---- ---- ---- ------
39 Linkage comes w/ perl yes yes yes yes yes
40 Src comes w/ perl no no yes no no
41 Comes w/ many unix os yes yes[0] no no no
42 Builds ok on !unix ? ? yes yes ?
43 Code Size ? ? small big big
44 Database Size ? ? small big? ok[1]
45 Speed ? ? slow ok fast
46 FTPable no no yes yes yes
47 Easy to build N/A N/A yes yes ok[2]
48 Size limits 1k 4k 1k[3] none none
49 Byte-order independent no no no no yes
50 Licensing restrictions ? ? no yes no
51
52 [0] on mixed universe machines, may be in the bsd compat library, which
53 is often shunned.
54
55 [1] Can be trimmed if you compile for one access method.
56
57 [2] See DB_File. Requires symbolic links.
58
59 [3] By default, but can be redefined.
60
62 dbm(3), ndbm(3), DB_File(3), perldbmfilter
63
64
65
66perl v5.8.8 2001-09-21 AnyDBM_File(3pm)