This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[dummy merge]
[perl5.git] / lib / AnyDBM_File.pm
CommitLineData
a0d0e21e 1package AnyDBM_File;
ca4f5ef1 2use vars qw(@ISA);
a0d0e21e
LW
3
4@ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
5
ca4f5ef1 6my $mod;
7for $mod (@ISA) {
8 return 1 if eval "require $mod"
9}
10
11die "No DBM package was successfully found or installed";
12#return 0;
f06db76b
AD
13
14=head1 NAME
15
16AnyDBM_File - provide framework for multiple DBMs
17
18NDBM_File, ODBM_File, SDBM_File, GDBM_File - various DBM implementations
19
20=head1 SYNOPSIS
21
22 use AnyDBM_File;
23
24=head1 DESCRIPTION
25
26This module is a "pure virtual base class"--it has nothing of its own.
27It's just there to inherit from one of the various DBM packages. It
28prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See
29L<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and
30finally ODBM. This way old programs that used to use NDBM via dbmopen()
31can still do so, but new ones can reorder @ISA:
32
33 @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File);
34
35Note, 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
40will only find GDBM_File.
41
42Having 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
51Here'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
73on mixed universe machines, may be in the bsd compat library,
74which is often shunned.
75
76=item [1]
77
78Can be trimmed if you compile for one access method.
79
80=item [2]
81
82See L<DB_File>.
83Requires symbolic links.
84
85=item [3]
86
87By default, but can be redefined.
88
89=back
90
91=head1 SEE ALSO
92
93dbm(3), ndbm(3), DB_File(3)
94
95=cut