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
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
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.
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.
Adding to PERL5LIB through /etc/profile, or a script inside of /etc/profile.d only works if your program is run from the command line. If you call it elsewhere, such as from a crontab entry, that will not work. What I do is add a line at the top of the program, under use strict, but before all other uses that looks like this:
push @INC, '/foo/bar' unless grep('/foo/bar', @INC);