ch0wn3d – Keeping your own Perl library and cpan in your home directory

ch0wned. adj. This is the state when you are a Linux user and don't have root access.

Intro

This tutorial is for people wanting to install perl modules using CPAN who do not have root access or wish to keep a network-central module repository that is separated from the local install.

Downloads

Installing

  1. Unpackage lib::local

    tar xvfz local-lib-1.008004.tar.gz

  2. Choose a library directory

    I use a value of $HOME which installs the modules into $HOME/lib/perl5

  3. Install lib::local into the above spot

    cd lib-local-1.008004
    perl Makefile.PL --bootstrap=$HOME
    make 
    make install

Running CPAN

eval `perl -I$HOME/lib/perl5 -Mlocal::lib=$HOME`
perl -I$HOME/lib/perl5 -Mlocal::lib=$HOME -MCPAN -e shell
cpan[1]> install Awesome::Module::From::CPAN

Now you can install modules from CPAN as normal as shown above. You might want to put the first two lines into a shell script named “my_cpan” or something.

Specifying your library path in your Perl scripts

use lib '/home/you/lib/perl5';
use Awesome::Module::From::CPAN;

Share and Enjoy:
  • Facebook
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Blogosphere News
  • email
  • LinkedIn
  • Print
  • Reddit
  • Slashdot
  • Add to favorites
  • RSS
  • Technorati
  • PDF

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">