This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mktables: Improve warning message
[perl5.git] / lib / AnyDBM_File.pm
CommitLineData
a0d0e21e 1package AnyDBM_File;
5f8b5b70
NC
2use warnings;
3use strict;
a0d0e21e 4
3b825e41 5use 5.006_001;
5f8b5b70 6our $VERSION = '1.01';
17f410f9 7our @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
a0d0e21e 8
ca4f5ef1 9my $mod;
10for $mod (@ISA) {
34d04c8d
CS
11 if (eval "require $mod") {
12 @ISA = ($mod); # if we leave @ISA alone, warnings abound
13 return 1;
14 }
ca4f5ef1 15}
16
17die "No DBM package was successfully found or installed";
5f8b5b70
NC
18
19__END__
f06db76b
AD
20
21=head1 NAME
22
23AnyDBM_File - provide framework for multiple DBMs
24
34d04c8d 25NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations
f06db76b
AD
26
27=head1 SYNOPSIS
28
29 use AnyDBM_File;
30
31=head1 DESCRIPTION
32
33This module is a "pure virtual base class"--it has nothing of its own.
34It's just there to inherit from one of the various DBM packages. It
35prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See
36L<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and
37finally ODBM. This way old programs that used to use NDBM via dbmopen()
38can still do so, but new ones can reorder @ISA:
39
34d04c8d
CS
40 BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
41 use AnyDBM_File;
f06db76b
AD
42
43Having multiple DBM implementations makes it trivial to copy database formats:
44
5f8b5b70 45 use Fcntl; use NDBM_File; use DB_File;
c954a603 46 tie %newhash, 'DB_File', $new_filename, O_CREAT|O_RDWR;
47 tie %oldhash, 'NDBM_File', $old_filename, 1, 0;
f06db76b
AD
48 %newhash = %oldhash;
49
50=head2 DBM Comparisons
51
52Here's a partial table of features the different packages offer:
53
54 odbm ndbm sdbm gdbm bsd-db
55 ---- ---- ---- ---- ------
56 Linkage comes w/ perl yes yes yes yes yes
57 Src comes w/ perl no no yes no no
58 Comes w/ many unix os yes yes[0] no no no
59 Builds ok on !unix ? ? yes yes ?
60 Code Size ? ? small big big
61 Database Size ? ? small big? ok[1]
62 Speed ? ? slow ok fast
63 FTPable no no yes yes yes
64 Easy to build N/A N/A yes yes ok[2]
65 Size limits 1k 4k 1k[3] none none
66 Byte-order independent no no no no yes
67 Licensing restrictions ? ? no yes no
68
69
70=over 4
71
72=item [0]
73
74on mixed universe machines, may be in the bsd compat library,
75which is often shunned.
76
77=item [1]
78
79Can be trimmed if you compile for one access method.
80
81=item [2]
82
83See L<DB_File>.
84Requires symbolic links.
85
86=item [3]
87
88By default, but can be redefined.
89
90=back
91
92=head1 SEE ALSO
93
9fe6733a 94dbm(3), ndbm(3), DB_File(3), L<perldbmfilter>
f06db76b
AD
95
96=cut