First, to set up the PERL5LIB environment variable, add the following to your
.bash_profile or equivalent:
if [ -z "$PERL5LIB" ]
then
# If PERL5LIB wasn't previously defined, set it...
PERL5LIB=~/perl5lib/lib
else
# ...otherwise, extend it.
PERL5LIB=$PERL5LIB:~/perl5lib/lib
fi
Reboot or source the file. Then, if you are having troubles, make sure you start with a clean user instalation.
> cd ~
> rm -rf .cpan
> rm -rf perl5lib
Create a folder to hold the modules, and start CPAN
> mkdir perl5lib
> cpan
Manual configuration should start, follow the instructions on screen, until at some point
the script asks you for any extra arguments for Makefile.PL. You should then supply (all in one line)
PREFIX=~/perl5lib LIB=~/perl5lib/lib INSTALLSITEMAN1DIR=~/perl5lib/man/man1
INSTALLSITEMAN3DIR=~/perl5lib/man/man3
When configuration finishes, make sure CPAN tells you it has writen the updated configuration file. If everything seems fine, type
quit.
To install a package now just type
cpan "Some::Module"
Source and more details
at Linux Gazette.