When using modules that are not installed in the standard directories
and we cannot assume (or require) to run the script in the same directory
where the module is. That is in most of the cases, we need to change @INC
so our script can find our module(s).
Set the environment variable
PERL5LIB or PERLLIB for all the scripts
use lib 'path/to/lib'; for the sepcific script
perl -I path/to/lib script.pl for this invocation only
# relative path
use FindBin;
use File::Spec;
use lib File::Spec->catfile($FindBin::Bin, '..', 'lib');
# relative path
use File::Spec;
use File::Basename;
use lib File::Spec->catfile(
File::Basename::dirname(File::Spec->rel2abs($0)),
'..',
'lib');
If you are interested in on-site trainings by the author, please
contact me directly.
|