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
and paste it in your terminal, and wait for it to do its job.
curl -L https://install.perlbrew.pl | bash
Now you will have to run
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
depending on your shell.
echo source ~/perl5/perlbrew/etc/bash >> ~/.zshrc
Once installed, you can see a list of different installable Perl versions by issuing the
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
and then checking the return value with
to see if it's 0 to be sure that you have them installed on your machine.
If the result of issuing
is non-zero after doing either of the above commands, then there is an issue, and you should install
gccbefore continuing. Installing these tools on Debian based systems is easy. Just run
to install them. And if you are on other Operating Systems you can use your corresponding commands to install them.
sudo apt install gcc make -y
As of this writing Perl version 5.34.1 is the latest stable version, so to install it, simply issue this command
and wait for it to compile and install Perl. This may take several minutes.
perlbrew install perl-5.34.1
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
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!).
perlbrew switch perl-5.34.1
I hope you have found this small guide useful.