Get the latest Perl release with perlbrew December 10, 2010Posted by claudio in Uncategorized.
Tags: GNU/Linux, Perl, perlbrew, UNIX
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.
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:
You may trash the downloaded /home/user/tmp/perlbrew from now on.
Next, if this is the first time you install perlbrew, run:
And follow the instruction on screen.
$ rm perlbrew
$ ~/lib/perlbrew/bin/perlbrew init
Perlbrew environment initiated, required directories are created under
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.1
For further instructions, simply run:
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):
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:
for the 64-bit version:
(Thanks to Ahmad!)
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
$ which 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…