From: Chip Salzenberg Date: Thu, 5 Sep 1996 21:14:21 +0000 (+1200) Subject: Limit @ISA to actual DBM in AnyDBM X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=34d04c8d9a0f251c651e2f9860ac3ffc476d363d;p=p5sagit%2Fp5-mst-13.2.git Limit @ISA to actual DBM in AnyDBM --- diff --git a/lib/AnyDBM_File.pm b/lib/AnyDBM_File.pm index e6a1503..aff3c7c 100644 --- a/lib/AnyDBM_File.pm +++ b/lib/AnyDBM_File.pm @@ -1,11 +1,14 @@ 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"; @@ -15,7 +18,7 @@ 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 @@ -30,14 +33,8 @@ L), GDBM, SDBM (which is always there--it comes with Perl), and 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: