Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: add remote dir to @INC

by jpl (Monk)
on May 25, 2011 at 16:42 UTC ( #906671=note: print w/replies, xml ) Need Help??

in reply to add remote dir to @INC

The devil is in the details of how you try to modify @INC.
push(@INC, "/my/directory"); use MyModule;
will not work.
use lib "/my/directory"; use MyModule;
should work.

use and BEGIN are evaluated "at compile time", before any other code is executed. So, in the first example use MyModule; is evaluated before @INC has been modified. The second example works because both statements are evaluated at compile time.

The PERL5LIB environment variable is, as was suggested, also useful. It, too, is processed at compile time.

Replies are listed 'Best First'.
Re^2: add remote dir to @INC
by kosta (Sexton) on May 25, 2011 at 17:32 UTC
    well that is what I did... I didnt even modify the PERL5LIB environment variable - I just created a symlink to my remote module folder in /System/Library/Perl/Extras/5.10.0. which already is in my INC, this didnt fix the issue however
      ok I got somewhere... maybe you can give me a hand here... when searching for modules "how deep" does perl descend? What happened to me that when I added to INC the whole remote modules folder but when I added site_perl folder (which was descended kinda deep in modules) it started working... Any way to make sure it does a complete recursive search?
        It does not recursively descend through the @INC directories. Read require (which is called by use). There is a slight exception when you use lib (see the 'auto' directory).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://906671]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2018-05-22 23:30 GMT
Find Nodes?
    Voting Booth?