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

How can I permenantly add a path to @INC? So that it will be in @INC every time i run perl?

Replies are listed 'Best First'.
Re: How to PERMENANTLY add to INC
by arturo (Vicar) on Nov 10, 2001 at 00:51 UTC

    AFAIK, you have a couple of options, only one of which does what you really ask:

    • recompile perl
      • sub-option: compile a private version of Perl that has the appropriate default @INC and use that version
    • set PERL5LIB so it includes the directories you want to add
    • (see perldoc perlrun for more on this)

    hth.

    perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
Re: How to PERMENANTLY add to INC
by premchai21 (Curate) on Nov 10, 2001 at 00:42 UTC

    The best way AFAICT is to use the environment variable PERL5LIB. So setting the environment variable PERL5LIB to, say, /foo/bar:/bar/foo before invoking perl will add /foo/bar and /bar/foo to @INC. If you want this to occur more than in your shell, you'll need to specify what sort of OS you're running.

    Another, less good way is to do an alias perl='perl -I/foo/bar -I/bar/foo' (or its equivalent, if you're not running bash); IMHO this is less correct however.

    HTH...

Re: How to PERMENANTLY add to INC
by hopes (Friar) on Nov 10, 2001 at 04:50 UTC
    Now a Windows solution ...
    At least, if you use ActiveState Perl you can set in the registry this key:
    HKEY_LOCAL_MACHINE\Software\Perl\lib to the path you can add permanently to @INC.
    Example:
    REGEDIT4 [HKEY_LOCAL_MACHINE\SOFTWARE\Perl] @="C:\\Perl" "bindir"="C:\\Perl\\bin" "lib"="c:\\perl\\site\\mylib"
    Greets
    Hopes