How to Install a Perl Module at a Custom Location

If you don't have permission to install a Perl module into the system Perl directories, you will not be able to use CPAN or yum or atp-get etc to install the module. You have to manually install it. Here are the steps:

  1. Download the module's package from search.cpan.org
  2. Install the package:

    $ tar zxf module-name.tgz
    $ cd module-name
    $ perl Makefile.PL PREFIX=/your-custom-dir
    $ make
    $ make test
    $ make install

  3. Set the environment variable to extending the library path -
    open your $HOME/.bashrc, and add the following line:

    PERL5LIB=/home/path/lib:/usr/another/path/lib; export PERL5LIB

  4. Test your installation and environment setup:

    $ PERL5LIB=/home/path/lib:/usr/another/path/lib; export PERL5LIB
    $ perl -e 'use module-name'

    If you don't see any error message, you have successfully installed and configured the Perl module in a local custom location.