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.
wget http://www.cpan.org/src/5.0/perl-5.18.0.tar.gz tar xf perl-5.18.0.tar.gz cd perl-5.18.0 mkdir /root/perl ./Configure -des -Dprefix=/root/perl make make install
Or a fully automated solution:
apt-get install build-essential PREFIX="/root/perl" URL=`curl -s http://www.cpan.org/src/README.html | grep 'wget' | sed 's|<[^>]*>||g' | sed 's/wget//g' | sed -e 's/^ *//g' -e 's/ *$//g'` FN="${URL##*/}" 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 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 CPAN.pm 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: http://www.perl.org/CPAN/MIRRORED.BY Looking for CPAN mirrors near you (please be patient) .......................... done! New urllist http://cpan.knowledgematters.net/ http://cpan.mirror.vexxhost.com/ http://httpupdate19.cpanel.net/CPAN/ Autoconfiguration complete. commit: wrote '/root/.cpan/CPAN/MyConfig.pm' 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. cpan[1]>
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 http://cpanmin.us | /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
Reference: http://perldoc.perl.org/CPAN.html#CPAN%3a%3aShell
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
cpan
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
Summary:
Install a local perl in /root/perl directory:
$wget http://www.cpan.org/src/5.0/perl-5.16.3.tar.gz $tar xf perl-5.16.3.tar.gz $cd perl-5.16.3 $mkdir /root/perl $./Configure -des -Dprefix=/root/perl $make $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
Then,
/root/perl/bin/perl -MCPAN -e 'install IO::Socket::SSL'
Useful modules:
/root/perl/bin/perl -MCPAN -e ‘install Mail::IMAPClient’
Term::ReadKey
/root/perl/bin/perl -MCPAN -e ‘install Net::SSL’
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
He is a full stack developer, whose favorite languages are currently Python and Vue.js. He is also fluent in Javascript, Flutter/Dart, Perl, PHP, SQL, C and bash shell scripting. He loves Linux, and can often be found tinkering with linux kernel code, and source code for GNU applications. He used to be an active developer on XDA forums, and his tinkered ROMS used to be very popular in the early 2000s.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.