[perl #128769] base.pm: Localize @INC unconditionally
authorFather Chrysostomos <[email protected]>
Tue, 2 Aug 2016 04:59:57 +0000 (21:59 -0700)
committerFather Chrysostomos <[email protected]>
Tue, 2 Aug 2016 05:00:45 +0000 (22:00 -0700)
As Zefram pointed out in
<https://rt.perl.org/Ticket/Display.html?id=128769#txn-1414015>,
having inconsistent behaviour is going to cause more problems
than solves.

dist/base/lib/base.pm

index 1093eb6..c7f9963 100644 (file)
@@ -97,8 +97,8 @@ sub import {
             {
                 local $SIG{__DIE__};
                 my $fn = _module_to_filename($base);
-                my $localinc = $INC[-1] eq '.';
-                local @INC = @INC[0..$#INC-1] if $localinc;
+                local @INC = @INC;
+                pop @INC if my $dotty = $INC[-1] eq '.';
                 eval {
                     require $fn
                 };
@@ -120,7 +120,7 @@ Base class package "$base" is empty.
     (Perhaps you need to 'use' the module which defines that package first,
     or make that module available in \@INC (\@INC contains: @INC).
 ERROR
-                    if ($localinc && -e $fn) {
+                    if ($dotty && -e $fn) {
                         $e .= <<ERROS;
     If you mean to load $fn from the current directory, you may
     want to try "use lib '.'".