in reply to PERL5LIB different than 'use lib'

This is a quote from lib:
For each directory in LIST (called $dir here) the lib module also checks to see if a directory called $dir/$archname/auto exists. If so the $dir/$archname directory is assumed to be a corresponding architecture specific directory and is added to @INC in front of $dir.
If there is a subdirectory named "auto", then use lib seems to behave more like PERL5LIB in that it will also search in the architecture-dependent subdirectory for your module.

Replies are listed 'Best First'.
Re^2: PERL5LIB different than 'use lib'
by almut (Canon) on May 07, 2009 at 03:01 UTC
    also checks to see if a directory called $dir/$archname/auto exists...

    Both PERL5LIB and use lib should behave the same in this respect. For example

    $ mkdir -p testlib/x86_64-linux-gnu-thread-multi/auto $ PERL5LIB=testlib perl -e'print join"\n",@INC' testlib/x86_64-linux-gnu-thread-multi testlib /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl $ perl -Mlib=testlib -e'print join"\n",@INC' testlib/x86_64-linux-gnu-thread-multi testlib /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl

    (the same applies to -Itestlib, btw)

      You'd think they should, but they don't. Try the following:
      $ PERL5LIB=/no/such/dir perl -le 'print for @INC' > foo $ PERL5LIB= perl -le 'use lib "/no/such/dir"; print for @INC' > bar $ diff -u foo bar--- foo 2009-05-07 16:24:12.000000000 -0700 +++ bar 2009-05-07 16:24:32.000000000 -0700 @@ -1,12 +1,3 @@ -/no/such/dir/5.8.6/x86_64-linux-thread-multi -/no/such/dir/5.8.6 -/no/such/dir/x86_64-linux-thread-multi -/no/such/dir/5.8.5 -/no/such/dir/5.8.4 -/no/such/dir/5.8.3 -/no/such/dir/5.8.2 -/no/such/dir/5.8.1 -/no/such/dir/5.8.0 /no/such/dir /usr/lib64/perl5/5.8.6/x86_64-linux-thread-multi /usr/lib/perl5/5.8.6
      And now we see the difference that saintmike was talking about. If you put stuff in $ENV{PERL5LIB}, it adds a list of internal hardcoded architecture specific directories to look in whether or not those directories exist, and regardless of the contents! By contrast use lib adds subdirectories based on a heuristic about their contents.

        This seems to be some (compile-time) configuration option, as none of my perls exhibit that behavior. I've tried with various versions from 5.8.4 to 5.10.0, self-built and/or those that ship with Debian and SUSE Linux. All do produce identical results for PERL5LIB and use lib (both existing and non-existing dirs).

        As you're getting directories for all kinds of versions, I guess it's the configure option that's scanning for other installations of Perl... (which I never use, as I explicitly do want to keep my versions separate).