perlbrew is a command line tool to intall Perl on user directries. You can install any version of Perl on your user directries and use it.
Installation of perlbrew
Execute the following command to install perlbrew.
curl -L http://install.perlbrew.pl | bash
If you don't have curl command, use wget command or fetch command.
# Linux wget -O - http://install.perlbrew.pl | bash # FreeBSD fetch -o- http://install.perlbrew.pl | sh
You can also install perlbrew from CPAN.
sudo cpan App::perlbrew perlbrew init
Add the perlbrew settings to "~/.bashrc".
echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc
Add the perlbrew settings to "~/.cshrc".
echo "source ~/perl5/perlbrew/etc/cshrc" >> ~/.cshrc
Installtion of Perl using perlbrew
You can check the available Perls using available command.
# Show the available Perls perlbrew available
Let's install a Perl using install command. The latest Perl version for 2022 is v5.34.1.
# Install Perl perlbrew install perl-5.34.1
If the installation of Perl fails, check the following commands are installled. These commands are needed to install Perl.
Show the list of installed Perls using list command.
# Show the list of installed Perls perlbrew list
The installed Perls are displayed.
And switch to the installed Perl.
perlbrew switch perl-5.34.1
And show the installed Perls again.
# Show the installed Perls perlbrew list
"*" is added to the head of the current Perl.
And see the Perl version.
The version of current Perl is displayed.
This is perl 5, version 34, subversion 1 (v5.34.1) built for x86_64-linux
Installation of cpanm
cpanm can be installed using install-cpanm command.
And install a module.
Modules are installed on the following directory in my case.
Returning back to System Perl
If you want to returning back to system Perl, use off command.