user288686
user288686

Reputation: 155

Downgrade perl version on mac

First of all am new to MAC.
Am facing similar kind of issue on Mac where its shipped with V5.28.0 but i have to use perl V5.18.2 for my application. Have installed perl 5.18.2 using perlbrew install 5.18.2 and the installation was successful.

Have two questions here

  1. Where are my default version and other version installed ? Is there any command to know them ? Have already tried checking echo $PATH but no use.

  2. How to set the default version to 5.18.2 ?

Regards
AVK

Upvotes: 1

Views: 2039

Answers (2)

Ashton Wiersdorf
Ashton Wiersdorf

Reputation: 2020

Another option (incompatible with perlbrew) is to use plenv. This lets you run different versions of perl for each directory. After installing with brew install plenv, you'd use it like so:

$ plenv install 5.18.2
$ cd project/needing/old/perl
$ echo "5.18.2" > .perl-version

Poof! Running perl in that directory or any of its subdirectories will use 5.18.2.

Note: if you run a perl script with ./script.pl, which has #!/usr/bin/perl, this should continue to use the perl installed at /usr/bin/perl. However, if the shebang line is /usr/bin/env perl, this should switch to the version specified by the .perl-version file.

Upvotes: 0

ikegami
ikegami

Reputation: 386551

The default installation location is

/usr/bin/perl

But that might not be where it's located on MacOS. You can find out for sure by running the following:

perlbrew off
which perl

(Restarting the terminal will reactivate perlbrew.)


The build you installed is in a directory under the directory returned by the following:

printf -- "%s\n" "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/perls"

You can modify the PATH so that perl runs the desired build using

perlbrew switch <name>     # Changes it for this shell instance and those created later.
perlbrew use <name>        # Changes it for this shell instance only.

You can get the names to use from

perlbrew list

See Switching to the system Perl using perlbrew for switching to the system Perl.


Scripts need to have the correct perl specified on their shebang (#!) line. Scripts installed by the standard Perl module installers will have this set correctly, but you'll need to edit the shebang (#!) line of scripts you've installed manually.

Upvotes: 2

Related Questions