Karan
Karan

Reputation: 15094

How to change default perl installation to the one installed by macports

I installed perl5.14 via macports.

By typing

which perl

I get

/usr/bin/perl

How do I change the perl to point the macports one.

My .profile is:

    # MacPorts Installer addition on 2012-02-02_at_14:42:32: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

Upvotes: 4

Views: 6483

Answers (4)

Ibmurai
Ibmurai

Reputation: 962

Maybe the perl port isn't active? try:

$ sudo port activate perl5

Upvotes: 5

tangent
tangent

Reputation: 561

You need to re-launch terminal for the export to take effect. As a quick but messy workaround you can always invoke perl like this: /opt/local/bin/perl Remember to put that in your Perl scripts as well. Also, unlike unix I find I always have to use sudo when installing to a local directory.

Macports is great for installing all those non-Perl libraries that aren't installed on the Mac, however it is not so great for installing Perl modules as it is dependant on there being a port of it, you can't really use CPAN to install. perlbrew does work on the Mac and is a much better solution. But if you still want to use Macports to install non-Perl libraries you hit a problem. I solved it with a .profile like this:

source ~/perl5/perlbrew/etc/bashrc
# export PATH=/opt/local/bin:/opt/local/sbin:$PATH

Note the comment. The first line gives me my perlbrew Perl when I open terminal. When I want to use Macports to install libraries I swap the comment around and re-launch terminal and I then have Macports Perl. Of course this means I need two Perls on my machine, and they both need to be the same version but I don't have any problems with this.

Upvotes: 3

ryandesign
ryandesign

Reputation: 1144

sudo port install perl5 +perl5_14

Upvotes: 4

Joel Berger
Joel Berger

Reputation: 20280

Not being on a Mac, I cannot answer your exact question. However, many Perl users/developers now use perlbrew to install newer versions of Perl and manage choosing between them. I am fairly confident that it works on Mac. Read more at the website or CPAN.

Upvotes: 0

Related Questions