Installing perlbrew on Centos/Rhel/Fedora

Published on Author gryzliLeave a comment
Installing perlbrew

Why you may need perlbrew ?

Perlbrew gives you the ability to maintain multiple perl versions, each having different set of install perl modules. The concept is not any new, we have already seen such things in Python (virtualenv) or Ruby (rvm).

Basically you get the following benefits (as state in the perlbrew site also):

  • No need to use ‘sudo’ in order to install packages from cpan
  • You could have as much versions as you like
  • Easily switch between perl versions or version with custom module sets
  • Getting out from the DIstro-shipped perl version
  • Setup seamless environment for all of your perl scripts running on different distro versions (for example if you have multiple Centos 5, 6,7 servers)

Installing perlbrew in custom directory

Installing of perlbrew is straight forward and easy. I prefer using user-defined custom directory for my perlbrew installation.

By default it will be installed in ~/perl5/perlbrew , which I don’t want.

For the current example, I’m going to install perlbrew in /usr/local/perlbrew .

 

 

Install custom perl version (5.24.0) under perlbrew

 

Now, as we already have perlbrew, we must go on and install alternative version. In the current example, I will install version “5.24.0”, but  you could install any other version.

 

1| Activate the perlbrew environment

 

2| Install perl 5.24.0

Installing the custom version is as easy as executing the following:

 

If you want to speed up the process (in my case about 5x times), you could disable testing and use multi-thread compilation .

This is the faster way to install your custom perl version:

-n - Stays for "not doing tests"

-j4 - Use 4 cores for parallel compilation

 

3| Install some custom modules

I prefer installing custom modules by using “cpanm”.

First you need to install cpanm:

Then you can easy install some custom module, for example “LWP::Protocol”

 

 

Using the newly installed perl

Here is example of how to use the newly installed version:

[email protected] [~]# perl -v  

[email protected] [~]# perlbrew  list

[email protected] [~]#  source /usr/local/perlbrew/etc/bashrc 
[email protected] [~]# perlbrew  switch perl-5.24.0                       
[email protected] [~]# perl -v  

 

Using perlbrew perl in cron

You may need to setup some cron scripts, where you want to use your newly installed alternative perl version. One easy way to do this is by using: “perlbrew-cron”, which could be found here:

perlbrew-cron

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha * Time limit is exhausted. Please reload CAPTCHA.