jump to navigation

Get the latest Perl release with perlbrew December 10, 2010

Posted by claudio in Uncategorized.
Tags: , , ,
trackback

Updated: January 7, 2014.

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 Perlwave 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.1

For 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  -Dcf_by="Your_name_here" -Dcf_email="Your_email@here"

If you run a 64-bit OS:  -Duse64bitall

Handy on Debian/Ubuntu: -Dpager=/usr/bin/sensible-pager

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…

About these ads

Comments»

1. App:cpanminus: zero-conf CPAN client « *n*x - December 10, 2010

[...] 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 [...]

2. Build Padre svn easily with perlbrew and cpanm « *n*x - December 10, 2010

[...] Install perlbrew and cpanm. You can follow my howtos here: perlbrew, [...]

3. Tweets that mention Get the latest Perl release with perlbrew « *n*x -- Topsy.com - December 10, 2010

[...] This post was mentioned on Twitter by saillinux, VM Brasseur. VM Brasseur said: Good perlbrew intro: http://bit.ly/fRKpUp #perl #perlbrew [...]

4. What I would love to see in 2011 for Perl « *n*x - January 1, 2011

[...] 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 [...]

5. superkuh - August 12, 2011

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?

claudio - September 9, 2011

Maybe .cpan is owned by root?

$ sudo chown -R $USER ~/.cpan

6. Perlbrew with options like threading « The Dumping Ground - April 24, 2012

[...] blog post on the *n*x blog gives a great description of how to install perl with threading, something that [...]

7. Apache2 mod_perl-2.0.9 perl 5.16.3 | VK5FJ - June 10, 2014

[…] For more see here and here. […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 145 other followers

%d bloggers like this: