Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: PERL5LIB different than 'use lib'

by almut (Canon)
on May 07, 2009 at 03:01 UTC ( [id://762472]=note: print w/replies, xml ) Need Help??


in reply to Re: PERL5LIB different than 'use lib'
in thread PERL5LIB different than 'use lib'

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)

Replies are listed 'Best First'.
Re^3: PERL5LIB different than 'use lib'
by tilly (Archbishop) on May 07, 2009 at 23:30 UTC
    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).

        That seems likely. I produced those results on a Red Hat box that someone else administers, so I have no idea how that Perl was built. Still if it happened on that machine, it could easily happen for someone else.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://762472]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-18 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found