[win32] merge change#896 from maintbranch
[p5sagit/p5-mst-13.2.git] / lib / lib.pm
index 546ae87..6e6e15e 100644 (file)
@@ -1,20 +1,34 @@
 package lib;
 
+use vars qw(@ORIG_INC);
 use Config;
 
 my $archname = $Config{'archname'};
 
-@ORIG_INC = ();                # (avoid typo warning)
 @ORIG_INC = @INC;      # take a handy copy of 'original' value
 
 
 sub import {
     shift;
     foreach (reverse @_) {
+       ## Ignore this if not defined.
+       next unless defined($_);
+       if ($_ eq '') {
+           require Carp;
+           Carp::carp("Empty compile time value given to use lib");
+                                                       # at foo.pl line ...
+       }
+       if (-e && ! -d _) {
+           require Carp;
+           Carp::carp("Parameter to use lib must be directory, not file");
+       }
        unshift(@INC, $_);
        # Put a corresponding archlib directory infront of $_ if it
        # looks like $_ has an archlib directory below it.
-       unshift(@INC, "$_/$archname") if -d "$_/$archname/auto";
+       if (-d "$_/$archname") {
+           unshift(@INC, "$_/$archname")    if -d "$_/$archname/auto";
+           unshift(@INC, "$_/$archname/$]") if -d "$_/$archname/$]/auto";
+       }
     }
 }
 
@@ -60,7 +74,6 @@ It is typically used to add extra directories to perl's search path so
 that later C<use> or C<require> statements will find modules which are
 not located on perl's default search path.
 
-
 =head2 ADDING DIRECTORIES TO @INC
 
 The parameters to C<use lib> are added to the start of the perl search
@@ -80,7 +93,6 @@ architecture specific directory and is added to @INC in front of $dir.
 If LIST includes both $dir and $dir/$archname then $dir/$archname will
 be added to @INC twice (if $dir/$archname/auto exists).
 
-
 =head2 DELETING DIRECTORIES FROM @INC
 
 You should normally only add directories to @INC.  If you need to
@@ -106,7 +118,6 @@ architecture specific directory and is also deleted from @INC.
 If LIST includes both $dir and $dir/$archname then $dir/$archname will
 be deleted from @INC twice (if $dir/$archname/auto exists).
 
-
 =head2 RESTORING ORIGINAL @INC
 
 When the lib module is first loaded it records the current value of @INC
@@ -118,7 +129,7 @@ can say
 
 =head1 SEE ALSO
 
-AddINC - optional module which deals with paths relative to the source file.
+FindBin - optional module which deals with paths relative to the source file.
 
 =head1 AUTHOR