15

On a standard linux set up, where can I add a directory to the @INC variable?

In the /etc/profile file, I added:

 export PERLLIB=$PERLLIB:/foo/bar
 export PERL5LIB=$PERL5LIB:/foo/bar

Thanks

brian d foy
  • 124,803
  • 31
  • 200
  • 568
paulj3000
  • 309
  • 2
  • 3
  • 8
  • 2
    You just answered your own question. What are you looking for other than that? – Ether Mar 25 '10 at 19:34
  • 1
    You only need to do PERL5LIB - PERLLIB is a fallback should PERL5LIB not be defined (and defining both IMHO causes confusion) – justintime Mar 27 '10 at 12:53
  • [Want to know how @INC is constructed?](http://stackoverflow.com/a/2526809/150371) – raksja Feb 28 '13 at 00:35

3 Answers3

2

You might also need to source your ~/.bashrc so that it rebuilds your environment, or log out and log back in, before this change takes effect. At least this would be required if you made that change in your local ~/.bash_profile instead of system wide.

Hugh Esco
  • 21
  • 1
2

If you want every Perl script to have the additional library paths, you can re-compile Perl and specify the extra directories as part of the setup. Other than that, you're stuck with the ad hoc methods as you describe.

brian d foy
  • 124,803
  • 31
  • 200
  • 568
-3

Below command helps to fix this issue. use lib "/usr/print";

Dinesh S
  • 1
  • 2