Using CPAN with a non-root account details customizing ~/.cpan/CPAN/MyConfig.pm and the Unix shell to use a custom directory for perl modules. While the following customize the PERL5LIB and MANPATH environment variables, editing the shell code is difficult:
if [ -d $HOME/lib/perl5 ]; then PERL5LIB=${PERL5LIB:+$PERL5LIB:}$HOME/lib/perl5 fi MANPATH=${MANPATH:+$MANPATH:}$HOME/share/man export MANPATH PERL5LIB
I currently use the following, which allows multiple directories to be listed, and the ordering of the directories changed easily in a text editor:
while read pf; do PERL5LIB=${PERL5LIB:+$PERL5LIB:}$pf done << EOPERL5LIB /sw/lib/perl5 $HOME/lib/perl5 EOPERL5LIB typeset -U PERL5LIB export PERL5LIB while read pf; do if [ -d $pf ]; then MANPATH=${MANPATH:+$MANPATH:}$pf fi done << EOMANPATH /sw/share/man /sw/man /usr/share/man /usr/X11R6/man /usr/local/share/man /usr/local/man /usr/local/pgsql/man $HOME/share/man EOMANPATH typeset -U MANPATH export MANPATH
This method works for all colon delimited environment variables, such as LD_LIBRARY_PATH, CLASSPATH, and others. Duplicate supression could be added, though would require additional code.
An even better option may be to template the shell configuration files, depending on the system. This way, complex source files would be rendered into minimal shell configuration files that need not perform any number of calculations for each new shell.