Manage Your Perl Installation with Perlbrew [Linux]

Perl is a great language, though some other programming languages like PHP and Ruby might have stolen a bit of its thunder.

While Perl has a reputation for being difficult to read, it’s really not that bad. If you’re comfortable writing shell scripts you should pick it up easily.

If you’re on a Linux or other Unix system, you probably have it already. But you probably don’t want to use the one that comes with your system. For one thing, it’s usually not the latest version, and second, it’s meant to support some utilities on the system rather than your own programs.

You could download a new version of Perl and compile it, but you risk messing up your system Perl. A better solution is using Perlbrew. It can compile and install multiple versions of Perl in your home directory, which means you won’t need superuser privileges to install it.


Installing it is easy enough. Perlbrew’s homepag has a line of code you can copy and paste into your terminal. You’ll need to have a C compiler installed first. To do this on Ubuntu, just use this command:

sudo apt-get install build-essential

You’ll get a whole bunch of development tools this way.

Once you’re set up, you can start installing versions of Perl.

To see which versions are available, just issue this command:

perlbrew available

Here’s a list of the available versions from when I ran it:

i perl-5.16.2

The “i” in front of the second one means that it is currently installed. Version 5.16.2 is the current version of Perl.

If it wasn’t installed on my system and I wanted to do so, I’d simply type this command:

perlbrew install perl-5.16.2

Then I’d go get a cup of coffee while it compiles.

To use it, just type this:

perlbrew switch perl-5.16.2

You can do this with any available version of Perl.

If you just want to play with a version of Perl in the current shell, just use this command:

perlbrew use perl-5.16.2

This is a good way to test a different version of Perl without committing to it. If you’re a serious developer, it’s a good idea to install several versions in order to test your program. Not everyone is going to have the latest version of Perl, since many distros ship with older versions.

Here’s an easy way to test a script against the installed version of Perl, shamelessly stolen from Perlbrew’s website:

perlbrew exec

You can read the manual page or simply type:

perlbrew help

to get more information. Perlbrew is a great way to have an updated Perl without stepping on the toes of your system’s default Perl, and it lets you experiment with different installations, from a more conservative older installation all the way to the bleeding edge.

The Perl community has always been awesome ever since the language’s debut in the late ’80s, and tools like this shows that Perl still has some life in it yet.

David Delony

David Delony is a writer for Make Tech Easier

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox