Wednesday, February 8, 2012

Install perl modules locally - Best approach

local::lib is a Perl module that sets everything up so you can install distributions from CPAN into your home directory.
Download it from http://search.cpan.org/dist/local-lib.
tar xvfz local-lib-1.008004.tar.gz
cd local-lib-1.008004
We now need to tell local::lib we want it to 'bootstrap' itself. This creates a 'perl5' folder within your home directory, and instructs the toolchain to install local::lib there.
perl Makefile.PL --bootstrap
Then, build, test and install local::lib:
make
make test
make install
Now set some environment variables that tell Perl where your installed modules are kept.
echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >>~/.bashrc
Test it:
perl -MCPAN -eshell
At the CPAN prompt, enter:
cpan[1]> install DBIx::Class::Schema::Loader