1

I find that my OSX 10.10 comes with perl 5.16 and 5.18. By default, when I run perl, I am using perl 5.18. Is there way for me to run perl 5.16 when I run perl command?

admins-Mac-mini:~ bufferoverflow76$ ls -l /usr/bin/perl*
-rwxr-xr-x   1 root  wheel  58416 Sep 10 10:06 /usr/bin/perl
-rwxr-xr-x   1 root  wheel  35600 Sep 10 10:06 /usr/bin/perl5.16
-rwxr-xr-x   1 root  wheel  35600 Sep 10 10:06 /usr/bin/perl5.18


admins-Mac-mini:~ bufferoverflow76$ perl -version

This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for mor

2 Answers2

1

You should be able to do this with either of the following commands:

defaults write com.apple.versioner.perl Version -string 5.16

or

export VERSIONER_PERL_VERSION=5.16

These are not system wide settings and only affect the user setting them.

Sources: http://krypted.com/mac-os-x/perl-control/ and https://gist.github.com/crankycoder/1389144

MJ Walsh
  • 403
0

If you want to avoid mucking with the base system, you could add an alias to your environment. For example, in your ~/.bashrc:

alias perl="/usr/bin/perl5.16"

Or add a symlink to /usr/bin/perl5.16 in your $PATH, which may be preferable. For example

ln -s /usr/bin/perl5.16 ~/bin/perl

Then in your ~/.bashrc, add:

export PATH=~/bin:$PATH

This won't address scripts that have a shebang line pointing directly to /usr/bin/perl, however.

For more sophisticated and convenient management of multiple Perl installs, consider using Perlbrew.

zackse
  • 662