http://www.perlmonks.org?node_id=1004011


in reply to Re: Overriding default libs
in thread Overriding default libs

The exact path of the .pm file is: /tmp/custom_module/lib/perl5/x86_64-linux-thread-multi/threads.pm

Replies are listed 'Best First'.
Re^3: Overriding default libs
by tobyink (Canon) on Nov 15, 2012 at 14:15 UTC

    Then you should use lib "/tmp/custom_module/lib/perl5";. (Perl should be able to guess the "x86_64-linux-thread-multi" bit.)

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      That worked perfectly, Thanks. How deep(how many sub-directory levels) does perl look when given a path for  use lib /path/... ?

        It doesn't look any levels down. If you:

        use lib "/tmp"; use Foo::Bar;

        ... then Perl will use "/tmp/Foo/Bar.pm", but not "/tmp/x/Foo/Bar.pm".

        The exception for your CPU architecture name (in your case "x86_64-linux-thread-multi") is due to some trickery by use lib which automatically detects those directories if they exist (and look like proper locations containing architecture-specific libraries), and unshifts two entries onto @INC instead of the normal one.

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re^3: Overriding default libs
by Anonymous Monk on Nov 15, 2012 at 14:15 UTC
    use lib '/tmp/custom_module/lib/perl5/x86_64-linux-thread-multi/';
      No,  use lib '/tmp/custom_module/lib/perl5';