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

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.

| improve this answer | |

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

defaults write com.apple.versioner.perl Version -string 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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.