First get the latest version number of perl, from cpan, and substitute that for the version number given below. Note that even numbered versions (like 18 in 5.18) are stable. Off numbered ones are development versions.

tar xf perl-5.18.0.tar.gz
cd perl-5.18.0
mkdir /root/perl
./Configure -des -Dprefix=/root/perl
make install

Or a fully automated solution:

apt-get install build-essential
URL=`curl -s | grep 'wget' | sed 's|<[^>]*>||g' | sed 's/wget//g' | sed -e 's/^ *//g' -e 's/ *$//g'`
echo wget $URL
wget $URL -O $FN
echo tar xf $FN
tar xf $FN
FOL=`echo $FN | sed 's/\.tar\.gz//g'`
cd $FOL
mkdir $PREFIX
./Configure -des -Dprefix="$PREFIX"
make install
"$PREFIX"/bin/perl -v
echo "Local perl installed to $PREFIX"
echo Be sure to export the variable with this path to some convenient variable, and set it in .bashrc:
echo   Eg. export PLOC="$PREFIX"/bin
echo Run cpan like this: $PLOC/cpan
echo To install a module: $PLOC/cpan -i App::cpanminus

Now run cpan:

Install Cpan:

[[email protected]] ~/perl #/root/perl/bin/perl -MCPAN -e shell requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes] yes

Autoconfigured everything but 'urllist'.

Now you need to choose your CPAN mirror sites.  You can let me
pick mirrors for you, you can select them from a list or you
can enter them by hand.

Would you like me to automatically choose some CPAN mirror
sites for you? (This means connecting to the Internet) [yes]
Trying to fetch a mirror list from the Internet
Fetching with HTTP::Tiny:

Looking for CPAN mirrors near you (please be patient)
.......................... done!

New urllist

Autoconfiguration complete.

commit: wrote '/root/.cpan/CPAN/'

You can re-run configuration any time with 'o conf init' in the CPAN shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.


Note that to use a local cpan, you have to do this:

/root/perl/bin/perl -MCPAN -e shell

where the initial perl path is path to local version of perl

Installing YAML:

If you dont know the install name of a module, you search for it like this:

i /YAML/

And you will get a long list:

Module  = YAML                   (MSTROUT/YAML-0.84.tar.gz)
Module  < YAML::Accessor         (ALEX/YAML-Accessor-0.44.tar.gz)
Module  < YAML::Active           (MARCEL/YAML-Active-1.100810.tar.gz)
Module  < YAML::Active::Concat   (MARCEL/YAML-Active-1.100810.tar.gz)
Module  < YAML::Active::Eval     (MARCEL/YAML-Active-1.100810.tar.gz)
Module  < YAML::Active::Include  (MARCEL/YAML-Active-1.100810.tar.gz)
Module  < YAML::Active::Plugin   (MARCEL/YAML-Active-1.100810.tar.gz)
Module  < YAML::Active::Plugin::Array (MARCEL/YAML-Active-1.100810.tar.gz)
Module  < YAML::Active::Plugin::Hash (MARCEL/YAML-Active-1.100810.tar.gz)
Module  < YAML::Active::Print    (MARCEL/YAML-Active-1.100810.tar.gz)
Module  < YAML::Active::Shuffle  (MARCEL/YAML-Active-1.100810.tar.gz)
Module  < YAML::Active::ValueMutator (MARCEL/YAML-Active-1.100810.tar.gz)

Once you get the install name, you can install it:

install YAML

If you wanted to install YAML::Active::lc from the list, you would do:

cpan> install YAML::Active::lc

Or from bash directly:

cpan -i YAML::Active::lc

Installing a module:

$/root/perl/bin/perl -MCPAN -e shell
cpan[2]> install Getopt::Long
cpan[2]> install WWW::Mechanize
cpan[2]> install File::Find::Rule

It can also be done directly from bash without entering the cpan shell:

/root/perl/bin/perl -MCPAN -e 'install Getopt::Long'

Easiest (New) way is:

/root/perl/bin/cpan -i Class::CSV

Install cpanminus on local perl version:

curl -L | /root/perl/bin/perl - App::cpanminus

Installing with local cpanm:

/root/perl/bin/cpanm -i IO::Socket::SSL

You might want to create a symlink to make this easy:

ln -s /root/perl/bin/cpanm /root/localcpanm

So you can run it with:

localcpanm -i IO::Socket::SSL


Note how the local CPAN is called for installation of module.

And directly installing a module from Bash: (May not be correct for a local version)

$ cpan -i DBI

Allow it to configure with defaults. When you come to the cpan> prompt, type:

cpan> o conf makepl_arg INSTALL_BASE=/root/perl
cpan> o conf commit

Install yaml:

cpan yaml

Install modules with:

install MODULE::NAME


Install a local perl in /root/perl directory:

$tar xf perl-5.16.3.tar.gz
$cd perl-5.16.3
$mkdir /root/perl
$./Configure -des -Dprefix=/root/perl
$make install
$/root/perl/bin/perl -MCPAN -e shell
cpan[2]> install YAML
cpan[2]> install Getopt::Long
cpan[2]> install WWW::Mechanize
cpan[2]> install File::Find::Rule

Install perl module IO::Socket::SSL

First install the following:

apt-get install libssl-dev libnet-ssleay-perl libio-socket-ssl-perl


/root/perl/bin/perl -MCPAN -e 'install IO::Socket::SSL'

Useful modules:

/root/perl/bin/perl -MCPAN -e ‘install Mail::IMAPClient’


/root/perl/bin/perl -MCPAN -e ‘install Net::SSL’