in reply to Re^2: How to execute/call perl module on different path ?
in thread How to execute/call perl module on different path ?

use lib $extra is (roughly) equivalent to BEGIN { unshift @INC,$extra }, so perl searches for libraries in $extra first. Your code

BEGIN { push( @INC, "/data/script" ); }

makes perl search for libraries in extra last, and only if no matching libraries were found in the original @INC.

That's hardly the same, and while it "works" in this special case, it will probably break in other situations.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^4: How to execute/call perl module on different path ?
by thomas895 (Deacon) on Jun 06, 2012 at 22:04 UTC

    Well, yeah, that is true. It is (hopefully) common knowledge that you can use any array modification technique to add your path.
    You could also add the path somewhere in the middle, if you really wanted. Or perhaps set it as the second element. Second to last, perhaps?
    It's just redundant to list all possibilities. And usually, good programmers take steps to avoid naming conflicts, regardless of where your code is stored.

    ~Thomas~
    confess( "I offer no guarantees on my code." );