January 09, 2018 — Team localos

We know what you are now thinking: "Perl ... oldfashioned and disgusting, not even the author of the code can read his source after two weeks." This might be true, but still Perl is a very powerful scripting language when it comes to quick and dirty (yeah, we know, really dirty) hacks, parsing, administrative task or research.

Perlbrew [1] is a kind of management tool for Perl installations. The power of this nifty tool is, that you can operate different Perl installations in parallel without messing up you system Perl. Thus it makes, e.g. testing a lot easier.

In this post, we'll briefly introduce Perlbrew and how to use it.

Installation and Configuration

Installtion, e.g. arch linux:

[user@blubs ~]$ sudo pacman -S perlbrew [user@blubs ~]$ perlbrew init

For use of, e.g. CPAN [2], installation of some additional stuff is recommended:

[user@blubs ~]$ perlbrew install-patchperl [user@blubs ~]$ perlbrew install-cpanm

Listing all available Perl versions and installing one:

[user@blubs ~]$ perlbrew available perl-5.21.7 perl-5.20.1 perl-5.18.4 perl-5.16.3 perl-5.14.4 perl-5.12.5 perl-5.10.1 perl-5.8.9 perl-5.6.2 perl5.005_04 perl5.004_05 perl5.003_07 [user@blubs ~]$ perlbrew install perl-5.21.7 [...] perl-5.21.7 is successfully installed.

Listing of all already install Perl versions:

The "*" marks the currently used Perl installation by Perlbrew, whereas which is used to find out which Perl is currently used in our environment.

[user@blubs ~]$ which perl /usr/bin/perl [user@blubs ~]$ perlbrew list * perl-5.21.7 [user@blubs ~]$ perlbrew switch perl-5.21.7 [user@blubs ~]$ perlbrew use Currently using perl-5.21.7 [user@blubs ~]$ which perl /home/user/perl5/perlbrew/perls/perl-5.21.7/bin/perl

Using Perlbrew to execute a program with all available (installed) Perl versions:

[user@blubs ~]$ perlbrew exec perl

Revert to system Perl as default:

[user@blubs ~]$ perlbrew switch-off

Using CPANM to update all installed modules:

[user@blubs ~]$ cpanm App::cpanoutdated [user@blubs ~]$ cpan-outdated -p | cpanm

Reinstall Perl modules after changing the Perl version (from 2.22.2 to 2.25.7):

[user@blubs ~]$ perlbrew use perl-2.22.2 [...] [user@blubs ~]$ perlbrew list-modules | perlbrew exec --with perl-5.25.7 cpanm [...]


Need threaded Perl? => NOT recommended !!!

[user@blubs ~]$ perlbrew install perl-5.22.2 -Dusethreads --as threaded-perl-5.22.2

Perlbrew switch is not working permanently?

[user@blubs ~]$ echo 'source ~/perl5/perlbrew/etc/bashrc' >> ~/.bash_profile

Perlbrew installation failed?

Could be some language settings, since some tests are checking against English. One solution might be:

[user@blubs ~]$ sudo echo 'LC_MESSAGES=en_US.UTF-8' >> /etc/locale.conf [user@blubs ~]$ echo 'export LC_MESSAGES=en_US.UTF-8' >> ~/.bashrc


Tags: perl, cpan, kb