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

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.

Replies are listed 'Best First'.
Re^4: PERL5LIB different than 'use lib'
by almut (Canon) on May 08, 2009 at 09:53 UTC

    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.
        ...it could easily happen for someone else.

        I never doubted that (nor that saintmike might not be telling the truth) — which is why I would've been interested in seeing his strace output... (as I initially suggested).