Installing Your Own Perl Modules

Sometimes you need to install Perl Modules in your OWN (non root) directory. 

% perl5 Makefile.PL PREFIX=/usr/home/USERNAME/usr/local
% make
% make test
% make install
% make clean

And then in your perl code you would use this near the top:

use lib qw(/usr/home/USERNAME/usr/local/lib/perl5);

There’s another writeup on using CPAN that didn’t work as well for me:

$ mkdir ~/.cpan
$ mkdir ~/.cpan/CPAN
$ cd ~/.cpan/CPAN
$ cp /usr/lib/perl5/5.8.4/CPAN/Config.pm MyConfig.pm
$ perl -pi -e's!/root/\.cpan!$ENV{HOME}/.cpan!' MyConfig.pm
$ perl -pi -e'/makepl_arg/ && s!\]! PREFIX=$ENV{HOME}]!' MyConfig.pm
$ echo "export PERL5LIB=${HOME}/lib/perl5/site_perl/5.8.4/i686-linux:${HOME}/lib/perl5/site_perl/5.8.4" >> ~/.bash_profile
$ . ~/.bash_profile
$ perl -MCPAN -e shell
Shopping Cart