This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
B/Deparse.pm: Rework deparsing of UTF-8 tr///
[perl5.git] / lib / AnyDBM_File.pm
... / ...
CommitLineData
1package AnyDBM_File;
2use warnings;
3use strict;
4
5use 5.006_001;
6our $VERSION = '1.01';
7our @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
8
9my $mod;
10for $mod (@ISA) {
11 if (eval "require $mod") {
12 @ISA = ($mod); # if we leave @ISA alone, warnings abound
13 return 1;
14 }
15}
16
17die "No DBM package was successfully found or installed";
18
19__END__
20
21=head1 NAME
22
23AnyDBM_File - provide framework for multiple DBMs
24
25NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations
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
40 BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
41 use AnyDBM_File;
42
43Having multiple DBM implementations makes it trivial to copy database formats:
44
45 use Fcntl; use NDBM_File; use DB_File;
46 tie %newhash, 'DB_File', $new_filename, O_CREAT|O_RDWR;
47 tie %oldhash, 'NDBM_File', $old_filename, 1, 0;
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
94dbm(3), ndbm(3), DB_File(3), L<perldbmfilter>
95
96=cut