Learn how to install Perl locally to solve Exercism's exercises on your own machine
The track targets the latest stable release of Perl.
It is possible to use older versions of Perl, but it may be necessary to make adjustments to the provided stub files for compatibility.
If you are unable to use the version specified in the stub files, it is recomended to replace use v5.XX;
with the following code:
use strict;
use warnings;
use feature qw<signatures>;
If the stub file contains use experimental qw<class>;
and the version of Perl you are using does not support this, you may either substitute this with use Feature::Compat::Class;
, or use an alternative Object Orientation system, e.g., Moo.
Perl is likely already installed, however it is possible that this may not be the latest version.
Run perl -v
to check which version you have.
If you wish to use a later version, check the 'Other Options' section.
If you are using Fedora/Red Hat/CentOS, some core modules are not included with Perl.
Use the yum install perl-core
command to install them.
Strawberry Perl: A 100% Open Source Perl for Windows that is exactly the same as Perl everywhere else; this includes using modules from CPAN, without the need for binary packages.
You can either install this directly from the site or use the chocolatey package manager.
$HOME
directory.
They are completely isolated Perl universes.If you are using a version of Perl older than 5.40, you will need to install the Test2::V0
testing bundle.
You will also need to install either Feature::Compat::Class
or an alternative Object Orientation system for OOP exercises.
Use the following instructions to set this up (or feel free to use your favorite module installer if you are already familiar with Perl):
Ensure that the exercism CLI has already been installed and configured.
Running exercism workspace
should show you the appropriate path.
Download the cpm
module installer and use it to install itself,
local::lib
, Test2::V0
, and Feature::Compat::Class
into your exercism/perl5
directory:
# *nix
curl -sL --compressed https://git.io/cpm | \
perl - install -L $(exercism workspace)/perl5 App::cpm local::lib Test2::V0 Feature::Compat::Class
# Microsoft PowerShell
(Invoke-WebRequest -UseBasicParsing 'https://git.io/cpm').Content |
perl - install -L "$(exercism workspace)/perl5" App::cpm local::lib Test2::V0 Feature::Compat::Class
local::lib
to set up your environment to use the modules you have
installed into exercism/perl5
:# *nix
eval $(perl -I$(exercism workspace)/perl5/lib/perl5 -Mlocal::lib=$(exercism workspace)/perl5)
# Microsoft PowerShell
perl -I"$(exercism workspace)/perl5/lib/perl5"
-M"local::lib=--shelltype=powershell,$(exercism workspace)/perl5" | Invoke-Expression
The environment changes from the above command will not persist, and will need to be rerun if you restart your shell.
If you would like your environment to be set up automatically each time, modify your .bashrc
(or *nix equivalent) or your PowerShell_profile.ps1
to include the above command.
The documentation for local::lib can be found here.
Alternatively, the package manager for your OS may have a Test2 Suite package available for you to install. Available options include: