in reply to Re: use lib current directory
in thread use lib current directory

hi Ken,
thx for hint, however all three rhel versions contain
... Compiled at Aug 7 2013 06:31:19 @INC: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .
with different compilation time ... kind of strange to me
so far didn't find anything suspicious in rhel release notes

Replies are listed 'Best First'.
Re^3: use lib current directory
by syphilis (Archbishop) on Feb 25, 2014 at 10:49 UTC
    If adding use lib "."; fixes a problem && "." is included in @INC, then my first thought is that something removes "." from @INC.

    I would think that this removal would have happened inside the perl code, and at compile time - eg inside a BEGIN{} block.
    So that would be the fist place to look.

    If you have a script in which you have included use lib ".";, try inserting immediately *before* that line:
    BEGIN {print "$_\n" for @INC;};
    If that shows you that "." was present during the execution of the BEGIN{} block, then the inclusion of use lib "."; would do nothing more than put "." at the *beginning* of @INC. That is, instead of having "." last in the @INC search path, it is now *first*.
    Could that be the key to the success with use lib "."; in your case ?

    (There are perhaps other scenarios that I've overlooked.)

    Cheers,
    Rob
      taint mode removes . from @INC ... relying on . is like relying on pwd , its unreliable
      hi rob,
      yes, use lib "."; moves the "." to the top - then it works ok
      still doesn't explain why new OS requires moving "." to the top
      1-/local/tmp/test/perlModules/x86_64-linux-thread-multi 1-/local/tmp/test/perlModules 1-/usr/local/lib64/perl5 1-/usr/local/share/perl5 1-/usr/lib64/perl5/vendor_perl 1-/usr/share/perl5/vendor_perl 1-/usr/lib64/perl5 1-/usr/share/perl5 1-.
      with use lib ".";
      2-. 2-/local/tmp/test/perlModules/x86_64-linux-thread-multi 2-/local/tmp/test/perlModules 2-/usr/local/lib64/perl5 2-/usr/local/share/perl5 2-/usr/lib64/perl5/vendor_perl 2-/usr/share/perl5/vendor_perl 2-/usr/lib64/perl5 2-/usr/share/perl5
      cheers,
      dan
        doesn't explain why new OS requires moving "." to the top

        I doubt that it's a requirement of the OS.
        If you have a module named FOO.pm in "." and also in (say) /usr/share/perl5, and your code contains use FOO; then, in the first instance, it's the FOO.pm from /usr/share/perl5 that gets loaded. But in the second instance it's the FOO.pm from "." that gets loaded.
        This happens because use FOO; tells perl to search through @INC from beginning to end, and load the first module named FOO.pm that it finds.

        So ... if there's some problem with the FOO.pm that's in /usr/share/perl5 but the one in "." is ok, then it makes a big difference whether "." is searched before or after /usr/share/perl5.

        I don't think you've told us the actual error you get if you don't use lib ".";
        What is that error message ?

        Cheers,
        Rob
Re^3: use lib current directory
by kcott (Archbishop) on Feb 25, 2014 at 10:39 UTC

    In that case, the issue may be the location of (potentially multiple copies of) modules and the order in which perl is finding them from @INC.

    In the following, note how '.' moves from $INC[-1] to $INC[0] (compare with my earlier perl -V output):

    #!/usr/bin/env perl -l use strict; use warnings; BEGIN { print "BEFORE use lib: @INC[0, -1]" } use lib '.'; BEGIN { print "AFTER use lib: @INC[0, -1]" }

    Output:

    BEFORE use lib: /Users/ken/local/lib/perl . AFTER use lib: . /Users/ken/perl5/perlbrew/perls/perl-5.18.1t/lib/5.1 +8.1

    -- Ken