Another way is to write code to modify @INC explicitly:
BEGIN {
unshift @INC,
qw(/home/stas/lib/perl5/5.00503
/home/stas/lib/perl5/5.00503/i386-linux
/home/stas/lib/perl5/site_perl/5.005
/home/stas/lib/perl5/site_perl/5.005/i386-linux);
}Note that with the lib module we don’t have to list the
corresponding architecture specific directories, since it adds them
automatically if they exist (to be exact, when //auto
exists).
Also, notice that both approaches prepend the directories to be
searched to @INC. This allows you to install a more recent module
into your local repository and Perl will use it instead of the older one
installed in the main system repository.
Both approaches modify the value of @INC at compilation time.
The lib module uses the BEGIN block as well, but
internally.
Now, let’s assume the following scenario. I have installed theLWP package in my local repository. Now I want to install another
module (e.g. mod_perl) and it has LWP listed in its prerequisites
list. I know that I have LWP installed, but when I run perlMakefile.PL for the module I’m about to install I’m told that I don’t
have LWP installed.
There is no way for Perl to know that we have some locally installed
modules. All it does is search the directories listed in @INC, and
since the latter contains only the default four directories (plus the. directory), it cannot find the locally installedLWP package. We cannot solve this problem by adding code to modify@INC, but changing the PERL5LIB environment variable
will do the trick. If you are using t?csh for interactive work, do
this:
: