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