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 Fcntl; 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 Here's a partial table of features the different packages offer:
35
36 odbm ndbm sdbm gdbm bsd-db
37 ---- ---- ---- ---- ------
38 Linkage comes w/ perl yes yes yes yes yes
39 Src comes w/ perl no no yes no no
40 Comes w/ many unix os yes yes[0] no no no
41 Builds ok on !unix ? ? yes yes ?
42 Code Size ? ? small big big
43 Database Size ? ? small big? ok[1]
44 Speed ? ? slow ok fast
45 FTPable no no yes yes yes
46 Easy to build N/A N/A yes yes ok[2]
47 Size limits 1k 4k 1k[3] none none
48 Byte-order independent no no no no yes
49 Licensing restrictions ? ? no yes no
50
51 [0] on mixed universe machines, may be in the bsd compat library, which
52 is often shunned.
53
54 [1] Can be trimmed if you compile for one access method.
55
56 [2] See DB_File. Requires symbolic links.
57
58 [3] By default, but can be redefined.
59
61 dbm(3), ndbm(3), DB_File(3), perldbmfilter
62
63
64
65perl v5.16.3 2013-03-04 AnyDBM_File(3pm)