@@ -3,9 +3,15 @@ package base;
33
44use strict ' vars' ;
55use vars qw( $VERSION) ;
6- $VERSION = ' 2.23 ' ;
6+ $VERSION = ' 2.23_01 ' ;
77$VERSION =~ tr / _// d;
88
9+ # simplest way to avoid indexing of the package: no package statement
10+ sub base ::__inc_scope_guard::DESTROY {
11+ my $noop = $_ [0][0];
12+ ref $_ and $_ == $noop and $_ = ' .' for @INC ;
13+ }
14+
915# constant.pm is slow
1016sub SUCCESS () { 1 }
1117
@@ -91,13 +97,17 @@ sub import {
9197
9298 next if grep $_ -> isa($base ), ($inheritor , @bases );
9399
94- # Following blocks help isolate $SIG{__DIE__} changes
100+ # Following blocks help isolate $SIG{__DIE__} and @INC changes
95101 {
96102 my $sigdie ;
97103 {
98104 local $SIG {__DIE__ };
99105 my $fn = _module_to_filename($base );
100- eval { require $fn };
106+ my $dotty = $INC [-1] eq ' .' && ( $INC [-1] = sub {()} );
107+ eval {
108+ my $redotty = $dotty && bless [ $dotty ], ' base::__inc_scope_guard' ;
109+ require $fn
110+ };
101111 # Only ignore "Can't locate" errors from our eval require.
102112 # Other fatal errors (syntax etc) must be reported.
103113 #
@@ -111,11 +121,24 @@ sub import {
111121 unless (%{" $base \: :" }) {
112122 require Carp;
113123 local $" = " " ;
114- Carp::croak( <<ERROR ) ;
124+ my $e = <<ERROR ;
115125Base class package "$base " is empty.
116126 (Perhaps you need to 'use' the module which defines that package first,
117127 or make that module available in \@ INC (\@ INC contains: @INC ).
118128ERROR
129+ if ($dotty && -e $fn ) {
130+ $e .= <<ERROS ;
131+ The file $fn does exist in the current directory. But note
132+ that base.pm, when loading a module, now ignores the current working
133+ directory if it is the last entry in \@ INC. If your software worked on
134+ previous versions of Perl, the best solution is to use FindBin to
135+ detect the path properly and to add that path to \@ INC. As a last
136+ resort, you can re-enable looking in the current working directory by
137+ adding "use lib '.'" to your code.
138+ ERROS
139+ }
140+ $e =~ s /\n\z / )\n / ;
141+ Carp::croak($e );
119142 }
120143 $sigdie = $SIG {__DIE__ } || undef ;
121144 }
0 commit comments