Installing Perl with perlbrew

I'm going to start this blog by writing a very simple guide on installing Perl using perlbrew.

To install Perl using perlbrew, first visit the website and grab its

curl -L https://install.perlbrew.pl | bash
and paste it in your terminal, and wait for it to do its job.

Now you will have to run

perlbrew init
to initialize perlbrew.

After that you will probably have to add it to your $PATH environment variable as the installation says after it is done downloading. This can be done with a command like

echo source ~/perl5/perlbrew/etc/bash >> ~/.bashrc
or
echo source ~/perl5/perlbrew/etc/bash >> ~/.zshrc
depending on your shell.

Once installed, you can see a list of different installable Perl versions by issuing the

perlbrew available
command.

Before trying to install Perl, you should ensure that you have make and a C compiler, which you probably already have if you are on Unix. I personally recommend the gcc (GNU Compiler Collection) which includes a C compiler. You can run

make -v
and
gcc -v
and then checking the return value with
echo $?
to see if it's 0 to be sure that you have them installed on your machine.

If the result of issuing

echo $?
is non-zero after doing either of the above commands, then there is an issue, and you should install make and/or gcc before continuing. Installing these tools on Debian based systems is easy. Just run
sudo apt install gcc make -y
to install them. And if you are on other Operating Systems you can use your corresponding commands to install them.

As of this writing Perl version 5.34.1 is the latest stable version, so to install it, simply issue this command

perlbrew install perl-5.34.1
and wait for it to compile and install Perl. This may take several minutes.

Now to use the freshly installed Perl and leaving the Operating System's Perl alone (which is located in /usr/bin/perl), you have to run the

perlbrew switch perl-5.34.1
command. This switches your default Perl to the new version that you have just installed, so that whenever you use Perl, you just use that instead of the system's Perl (which is not to be messed with!).

I hope you have found this small guide useful.

Leave a comment

About Deadmarshal

user-pic I love Perl :)