This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: installperl feature request (was: Re: Upgrade 4.0x to 5.001m)
[perl5.git] / lib / AnyDBM_File.pm
CommitLineData
a0d0e21e
LW
1package AnyDBM_File;
2
3@ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
4
5eval { require NDBM_File } ||
6eval { require DB_File } ||
7eval { require GDBM_File } ||
8eval { require SDBM_File } ||
9eval { require ODBM_File };
f06db76b
AD
10
11=head1 NAME
12
13AnyDBM_File - provide framework for multiple DBMs
14
15NDBM_File, ODBM_File, SDBM_File, GDBM_File - various DBM implementations
16
17=head1 SYNOPSIS
18
19 use AnyDBM_File;
20
21=head1 DESCRIPTION
22
23This module is a "pure virtual base class"--it has nothing of its own.
24It's just there to inherit from one of the various DBM packages. It
25prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See
26L<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and
27finally ODBM. This way old programs that used to use NDBM via dbmopen()
28can still do so, but new ones can reorder @ISA:
29
30 @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File);
31
32Note, 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
37will only find GDBM_File.
38
39Having multiple DBM implementations makes it trivial to copy database formats:
40
41 use POSIX; use NDBM_File; use DB_File;
c954a603 42 tie %newhash, 'DB_File', $new_filename, O_CREAT|O_RDWR;
43 tie %oldhash, 'NDBM_File', $old_filename, 1, 0;
f06db76b
AD
44 %newhash = %oldhash;
45
46=head2 DBM Comparisons
47
48Here'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
70on mixed universe machines, may be in the bsd compat library,
71which is often shunned.
72
73=item [1]
74
75Can be trimmed if you compile for one access method.
76
77=item [2]
78
79See L<DB_File>.
80Requires symbolic links.
81
82=item [3]
83
84By default, but can be redefined.
85
86=back
87
88=head1 SEE ALSO
89
90dbm(3), ndbm(3), DB_File(3)
91
92=cut