xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/AnyDBM_File.pm (revision 0:68f95e015346)
1*0Sstevel@tonic-gatepackage AnyDBM_File;
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateuse 5.006_001;
4*0Sstevel@tonic-gateour $VERSION = '1.00';
5*0Sstevel@tonic-gateour @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gatemy $mod;
8*0Sstevel@tonic-gatefor $mod (@ISA) {
9*0Sstevel@tonic-gate    if (eval "require $mod") {
10*0Sstevel@tonic-gate	@ISA = ($mod);	# if we leave @ISA alone, warnings abound
11*0Sstevel@tonic-gate	return 1;
12*0Sstevel@tonic-gate    }
13*0Sstevel@tonic-gate}
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gatedie "No DBM package was successfully found or installed";
16*0Sstevel@tonic-gate#return 0;
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gate=head1 NAME
19*0Sstevel@tonic-gate
20*0Sstevel@tonic-gateAnyDBM_File - provide framework for multiple DBMs
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gateNDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gate=head1 SYNOPSIS
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gate    use AnyDBM_File;
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gate=head1 DESCRIPTION
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gateThis module is a "pure virtual base class"--it has nothing of its own.
31*0Sstevel@tonic-gateIt's just there to inherit from one of the various DBM packages.  It
32*0Sstevel@tonic-gateprefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See
33*0Sstevel@tonic-gateL<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and
34*0Sstevel@tonic-gatefinally ODBM.   This way old programs that used to use NDBM via dbmopen()
35*0Sstevel@tonic-gatecan still do so, but new ones can reorder @ISA:
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gate    BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
38*0Sstevel@tonic-gate    use AnyDBM_File;
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gateHaving multiple DBM implementations makes it trivial to copy database formats:
41*0Sstevel@tonic-gate
42*0Sstevel@tonic-gate    use POSIX; use NDBM_File; use DB_File;
43*0Sstevel@tonic-gate    tie %newhash,  'DB_File', $new_filename, O_CREAT|O_RDWR;
44*0Sstevel@tonic-gate    tie %oldhash,  'NDBM_File', $old_filename, 1, 0;
45*0Sstevel@tonic-gate    %newhash = %oldhash;
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gate=head2 DBM Comparisons
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gateHere's a partial table of features the different packages offer:
50*0Sstevel@tonic-gate
51*0Sstevel@tonic-gate                         odbm    ndbm    sdbm    gdbm    bsd-db
52*0Sstevel@tonic-gate			 ----	 ----    ----    ----    ------
53*0Sstevel@tonic-gate Linkage comes w/ perl   yes     yes     yes     yes     yes
54*0Sstevel@tonic-gate Src comes w/ perl       no      no      yes     no      no
55*0Sstevel@tonic-gate Comes w/ many unix os   yes     yes[0]  no      no      no
56*0Sstevel@tonic-gate Builds ok on !unix      ?       ?       yes     yes     ?
57*0Sstevel@tonic-gate Code Size               ?       ?       small   big     big
58*0Sstevel@tonic-gate Database Size           ?       ?       small   big?    ok[1]
59*0Sstevel@tonic-gate Speed                   ?       ?       slow    ok      fast
60*0Sstevel@tonic-gate FTPable                 no      no      yes     yes     yes
61*0Sstevel@tonic-gate Easy to build          N/A     N/A      yes     yes     ok[2]
62*0Sstevel@tonic-gate Size limits             1k      4k      1k[3]   none    none
63*0Sstevel@tonic-gate Byte-order independent  no      no      no      no      yes
64*0Sstevel@tonic-gate Licensing restrictions  ?       ?       no      yes     no
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate=over 4
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gate=item [0]
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gateon mixed universe machines, may be in the bsd compat library,
72*0Sstevel@tonic-gatewhich is often shunned.
73*0Sstevel@tonic-gate
74*0Sstevel@tonic-gate=item [1]
75*0Sstevel@tonic-gate
76*0Sstevel@tonic-gateCan be trimmed if you compile for one access method.
77*0Sstevel@tonic-gate
78*0Sstevel@tonic-gate=item [2]
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gateSee L<DB_File>.
81*0Sstevel@tonic-gateRequires symbolic links.
82*0Sstevel@tonic-gate
83*0Sstevel@tonic-gate=item [3]
84*0Sstevel@tonic-gate
85*0Sstevel@tonic-gateBy default, but can be redefined.
86*0Sstevel@tonic-gate
87*0Sstevel@tonic-gate=back
88*0Sstevel@tonic-gate
89*0Sstevel@tonic-gate=head1 SEE ALSO
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gatedbm(3), ndbm(3), DB_File(3), L<perldbmfilter>
92*0Sstevel@tonic-gate
93*0Sstevel@tonic-gate=cut
94