Perlbrew

From Asenjo
Revision as of 22:12, 28 August 2015 by Natxo (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Installing a system-wide perlbrew Perl

perlbrew for multiple users

  1. create a directory where perlbrew will install the new Perl version:
# mkdir /opt/perl5 [enter]

I chose to do it in /opt/perl5; if we change the permissions on this directory, we do not need to run the rest as root.

  1. declare a (temporary) environment variable PERLBREW_ROOT
$ export PERLBREW_ROOT=/opt/perl5
  1. download the perlbrew script and run it:
$ curl -L http://xrl.us/perlbrewinstall | bash [enter]
$ /opt/perlbrew/bin/perlbrew init [enter]

I actually reviewed the script before executing it, do not just run stuff off the internet without knowing what you are doing.

  1. modify your login script

In my case I use the bash shell, so I modified my .bashrc file (log off and back in to see the changes later):

export PERLBREW_ROOT=/opt/perl5
source /opt/perl5/etc/bashrc
source /opt/perl5/etc/perlbrew-completion.bash

After this, just install a new Perl version. You will need a c compiler, make and patch:

$ perlbrew install perl-5.14.2 [enter]
$ perlbrew switch perl-5.14.2 [enter]

The 1st step could take a long time depending on how fast your host is. After it is done, you will have a new Perl at your disposal.

$ perl -v

This is perl 5, version 14, subversion 2 (v5.14.2) built for i686-linux

Copyright 1987-2011, Larry Wall
.....

and this is the system's Perl:

$ /usr/bin/perl -v

This is perl, v5.10.1 (*) built for i386-linux-thread-multi

Copyright 1987-2009, Larry Wall
....

compile perl for intel 32bits in a 64bits intel host

With perlbrew you can also cross compile Perl for other processor architectures. This is how I did it for i686.

In a redhat host you need the 32 compilers, libraries etc to do it.

$ perlbrew install perl-5.14.2 --as perl-5.14.2-i686-linux-thread-mult -Dcc='cc -m32' -Dplibpth='/lib64 /usr/lib64 /usr/lib/ /usr/lib/x86_64-linux-gnu/' -Darchname=i686-linux-thread-multi -Dusethreadscc='cc -m32' -Dplibpth='/lib64 /usr/lib64 /usr/lib/ /usr/lib'

This will compile everything to your defined PERLBREW_ROOT dir.

When it's done, just switch to it:

$ perlbrew use perl-5.14.2-i686-linux-thread-mult
$ perl -v

This is perl 5, version 14, subversion 2 (v5.14.2) built for i686-linux-thread-multi