Get the latest Perl release with perlbrew December 10, 2010
Posted by claudio in Uncategorized.Tags: GNU/Linux, Perl, perlbrew, UNIX
trackback
Updated: March 12, 2011.
Sometimes you want to leave your system Perl installation in peace and don’t really want to mix the system supplied Perl Modules and newer versions from CPAN. Or you want to use CPAN without sudo and without using PERL5LIB or local::lib. Or you may to test your code on older Perl releases. Or you simply can’t wait to use that shiny latest Perl release.
Good news. Perlbrew is a very nice addition to the “Modern Perl” wave resulting in a language and community revival of Perl 5 (that seems to have revitalized Perl 6 at the same time).
From the perlbrew CPAN page:
perlbrew is a program to automate the building and installation of perl in the user’s HOME. At the moment, it installs everything to ~/perl5/perlbrew, and requires you to tweak your PATH by including a bashrc/cshrc file it provides. You then can benefit from not having to run ‘sudo’ commands to install cpan modules because those are installed inside your HOME too. It’s a completely separate perl environment.
Here you’ll find how to use and customize perlbrew on a Debian/Ubuntu or Solaris installation. You don’t need g++ for perlbrew, but some modules from CPAN may need it later:
$ sudo apt-get install g++ curl
In case you use Solaris, install the Sunstudio compiler and make sure make and ar are in your PATH:
$ export PATH=/usr/bin:/usr/sbin:/opt/SUNW/spro/bin:/usr/ccs/bin
$ mkdir ~/lib
$ curl -LO http://xrl.us/perlbrew[...]
$ chmod +x perlbrew
The directory ~/perl5/perlbrew will contain all install perl executables, libraries, documentations, lib, site_libs. In case you don’t like the default, you can change it with the PERLBREW_ROOT shell variable. Change , and accordingly to your installation.
$ export PERLBREW_ROOT=~/lib/perlbrew
$ ./perlbrew install
The perlbrew is installed as:
/home/user/lib/perlbrew/bin/perlbrew
You may trash the downloaded /home/user/tmp/perlbrew from now on.
Next, if this is the first time you install perlbrew, run:
/home/user/lib/perlbrew/bin/perlbrew init
And follow the instruction on screen.
$ rm perlbrew
$ ~/lib/perlbrew/bin/perlbrew init
Perlbrew environment initiated, required directories are created under
/home/user/lib/perlbrew
Well-done! Congratulations! Please add the following line to the endof your ~/.bashrc.
After that, exit this shell, start a new one, and install some freshperls:
perlbrew install perl-5.12.1
perlbrew install perl-5.10.1For further instructions, simply run:
perlbrew
The default help messages will popup and tell you what to do!
Enjoy perlbrew at $HOME!!
$ echo "source /home/$USER/lib/perlbrew/etc/bashrc" >> ~/.bashrc
$ source ~/.bashrc
You can install new perl releases by typing by example “perlbrew install perl-5.12.3″. However, it may be a good idea to enable some features on the new compiled perl (mostly taken from the Ubuntu/Debian compile), specially the enabling of threading needed by a lot of perl programs (e.g. Padre):
$ perlbrew install perl-5.12.3 -Dusethreads -Duselargefiles -Dcccdlflags=-fPIC -Dpager=/usr/bin/sensible-pager -Doptimize=-O2 -Duseshrplib -Dcf_by="Your_name_here" -Dcf_email="Your_email@here"
Add the applicable parameters if you run a 64-bit OS or a Debian-based OS (like Debian or Ubuntu):
64-bit OS: -Duse64bitall
Debian-based OS: -Darchname=x86_64-linux-gnu -Dccflags=-DDEBIAN
Update if you are running Ubuntu 11.04. Ubuntu removed some links to libraries so if you build a Perl version previous 5.14, you need to the following:
for the 32-bit version: -Dplibpth=/usr/lib/i386-linux-gnu
for the 64-bit version: -Dplibpth=/usr/lib/x86_64-linux-gnu
(Thanks to Ahmad!)
Output:
[...]
Installed perl-5.12.3 as perl-5.12.3 successfully. Run the following command to switch to it: perlbrew switch perl-5.12.3
If you have several perl releases installed , you can choose the main perl by typing:
$ perlbrew switch perl-5.12.3
$ which perl
/home/claudio/lib/perlbrew/perls/perl-5.12.3/bin/perl
$ which cpan
/home/claudio/lib/perlbrew/perls/perl-5.12.3/bin/cpan
$ perl -v
This is perl 5, version 12, subversion 3 (v5.12.3) built for x86_64-linux-gnu-thread-multi
Copyright 1987-2010, Larry Wall
Perl may be copied only under the terms of either the Artistic License or theGNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found onthis system using “man perl” or “perldoc perl”. If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
A shiny new Perl to play work with…
[...] UNIX, GNU/Linux, Perl, Programming, Solaris, Ubuntu, UNIX. trackback App::cpanminus (cpanm) is an other great example of programs inscribed in the Modern Perl philosophy. From the CPAN page of the [...]
[...] Install perlbrew and cpanm. You can follow my howtos here: perlbrew, [...]
[...] This post was mentioned on Twitter by saillinux, VM Brasseur. VM Brasseur said: Good perlbrew intro: http://bit.ly/fRKpUp #perl #perlbrew [...]
[...] at FOSDEM and CEBITT, the 10.000.000th (!!!!!) test report on CPAN thanks to the CPAN Testers, perlbrew, cpanminus, the release of the book Effective Perl Programming (2nd ed.) and Modern [...]
Thanks for the guide. I pretty much just copied your steps verbatim, but when I went to actually start using cpan the autoconfiguration failed with: “Couldn’t find directory /home/superkuh/.cpan
or directory is not writable. Please retry.”
which cpan returns, “/home/superkuh/lib/perlbrew/perls/perl-5.12.3/bin/cpan”. Could you advise me on where to point cpan within the perlbrew dist. for 5.12.3 for it’s directory?
Maybe .cpan is owned by root?
$ sudo chown -R $USER ~/.cpan
[...] blog post on the *n*x blog gives a great description of how to install perl with threading, something that [...]