jonjacobmoon has asked for the wisdom of the Perl Monks concerning the following question:

Seems like this should be a basic question but I have not been able to find an easy answer: how do I add to @INC permanently? I see that I can change the PERLLIB environmentaly variable but where do I do that? It is not clear.


I admit it, I am Paco.

Replies are listed 'Best First'.
(wil) Re: Adding a directory to @INC permenantly
by wil (Priest) on Jul 02, 2002 at 17:44 UTC
    You may be interested in a few suggestions offered in a recent thread on this topic. Specifically, look for mikfire's dirty hack which seems to work.

    For more information on PERL5LIB, or PERLLIB if PERL5IB is not defined, take a look at perldoc perlrun.

    Hope this helps.

    - wil
Re: Adding a directory to @INC permenantly
by jdavidboyd (Friar) on Jul 02, 2002 at 18:42 UTC
    Perl FAQ 8 offers the following, under the question of:

    How do I add a directory to my include path at runtime?

    Here are the suggested ways of modifying your include path:

       the PERLLIB environment variable
       the PERL5LIB environment variable
       the perl -Idir command line flag
       the use lib pragma, as in
          use lib "$ENV{HOME}/myown_perllib";

    The latter is particularly useful because it knows about machine dependent architectures. The lib.pm pragmatic module was first included with the 5.002 release of Perl.

    Myself, I go for the perl -Idir version.
Re: Adding a directory to @INC permenantly
by Aristotle (Chancellor) on Jul 02, 2002 at 17:49 UTC
    If this is a Unix system and the scripts are run by the webserver, you will need root access; then you can add the variable to /etc/profile. If you run the scripts yourself (or a program you started does), then you might simply add the variable to your .profile or .bashrc or whatever.

    Makeshifts last the longest.

      Doh! Of course, frustration, late nights, and plain stupidity got the best of me :) Thanks, Aristotle.


      I admit it, I am Paco.
Re: Adding a directory to @INC permenantly
by perrin (Chancellor) on Jul 02, 2002 at 17:53 UTC
    Where do you change an environment variable? In your shell. That won't help with CGI scripts though, since they don't run as you.

    By far the best way to do this is by compiling perl with your customized lib path. Look at the install docs for instructions.