package AnyDBM_File;
-use vars qw(@ISA);
+use vars qw(@ISA);
@ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
my $mod;
for $mod (@ISA) {
- return 1 if eval "require $mod"
+ if (eval "require $mod") {
+ @ISA = ($mod); # if we leave @ISA alone, warnings abound
+ return 1;
+ }
}
die "No DBM package was successfully found or installed";
AnyDBM_File - provide framework for multiple DBMs
-NDBM_File, ODBM_File, SDBM_File, GDBM_File - various DBM implementations
+NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations
=head1 SYNOPSIS
finally ODBM. This way old programs that used to use NDBM via dbmopen()
can still do so, but new ones can reorder @ISA:
- @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File);
-
-Note, however, that an explicit use overrides the specified order:
-
- use GDBM_File;
- @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File);
-
-will only find GDBM_File.
+ BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
+ use AnyDBM_File;
Having multiple DBM implementations makes it trivial to copy database formats: