Modifying @INC is quite easy. The best approach is to use the lib module (pragma) by adding the following snippet at the top of any of your scripts that require the locally installed modules:
use lib qw(/home/stas/lib/perl5/5.6.1/ /home/stas/lib/perl5/site_perl/5.6.1 /home/stas/lib/perl5/site_perl );
Another way is to write code to modify @INC explicitly:
BEGIN { unshift @INC, qw(/home/stas/lib/perl5/5.6.1/i386-linux /home/stas/lib/perl5/5.6.1 /home/stas/lib/perl5/site_perl/5.6.1/i386-linux /home/stas/lib/perl5/site_perl/5.6.1 /home/stas/lib/perl5/site_perl ); }
Note that with the lib module, we don't have to list the corresponding architecture-specific directories—it adds them automatically if they exist (to be exact, when $dir/$archname/auto exists). It also takes care of removing any duplicated entries.
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, which Perl will then use 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 internally.
 
Continue to: