Start anew
[msysgit.git] / lib / perl5 / 5.6.1 / AnyDBM_File.pm
blob58ffda768e2af229ae2323711282fec9a2d4759f
1 package AnyDBM_File;
3 use 5.005_64;
4 our @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
6 my $mod;
7 for $mod (@ISA) {
8 if (eval "require $mod") {
9 @ISA = ($mod); # if we leave @ISA alone, warnings abound
10 return 1;
14 die "No DBM package was successfully found or installed";
15 #return 0;
17 =head1 NAME
19 AnyDBM_File - provide framework for multiple DBMs
21 NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations
23 =head1 SYNOPSIS
25 use AnyDBM_File;
27 =head1 DESCRIPTION
29 This module is a "pure virtual base class"--it has nothing of its own.
30 It's just there to inherit from one of the various DBM packages. It
31 prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See
32 L<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and
33 finally ODBM. This way old programs that used to use NDBM via dbmopen()
34 can still do so, but new ones can reorder @ISA:
36 BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
37 use AnyDBM_File;
39 Having multiple DBM implementations makes it trivial to copy database formats:
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;
46 =head2 DBM Comparisons
48 Here's a partial table of features the different packages offer:
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
66 =over 4
68 =item [0]
70 on mixed universe machines, may be in the bsd compat library,
71 which is often shunned.
73 =item [1]
75 Can be trimmed if you compile for one access method.
77 =item [2]
79 See L<DB_File>.
80 Requires symbolic links.
82 =item [3]
84 By default, but can be redefined.
86 =back
88 =head1 SEE ALSO
90 dbm(3), ndbm(3), DB_File(3), L<perldbmfilter>
92 =cut