views:

924

answers:

5

I'm about to get a new iMac. It's my first Intel mac and will presumably come with Snow Leopard. What would other users recommend as the right strategy for installing and using perl on this machine?

I know I've read some complaints about the version of Perl (or was it the version of CPAN?) shipped with Leopard, although a quick google isn't coming up with much.

I'm assuming that a good strategy is to leave the system perl alone and install my own, but what would you use? Fink, Darwinports, maybe XAMPP for Mac?

Are there any particular gotchas for someone who hasn't used Perl on Intel macs before?

I'm not exactly a power developer, but I have quite a few utility scripts and MySQL database applications which run on my old machine I'm going to want to keep, and my main work is web development.

+3  A: 

IMHO, it's always a good idea to avoid the system perl on any OS and install your own. On MacOS X, I've always had good luck just downloading the source and compiling it. (This will require an install of the MacOS X Developer Tools to get gcc and whatnot; it's not installed by default.)

friedo
+4  A: 

If you're like me you will be installing macports anyway (I use it for mutt, colordiff, fetchmail+ssl etc), which means you will have ended up with a second perl in /opt/local/bin/perl, which will also result in a huge number of cpan modules being added to /opt/local/lib. These will be entirely separate from the the system perl (installed into /System/Library). Since macports only installs perl 5.8.9 by default (at least, that's what I ended up with via dependencies after installing lots of macports distributions), and Apple is still bundling perl5.10.0 with 10.6.2, you will probably want to install a third perl (version 5.10.1), somewhere else. Now this is starting to get complicated...

See this question and particularly brian d foy's answer to How do you manage your Perl modules?. He discusses his strategies for installing multiple perls and managing its modules.

For me, I can't see a need for versions other than 5.8.9 and 5.10.1, so I simply downloaded/installed 5.10.1 from source directly into /usr/local/lib and /usr/local/bin (i.e. ./Configure -de -Dprefix=/usr/local), where my PATH uses the order /usr/local/bin:/opt/local/bin:/usr/bin. I will not make any modifications at all to the system perl: Apple will update components as needed for its internal systems. Furthermore, I will not make any (manual) modifications to the macports perl: new modules will be downloaded and installed via dependencies as I install new tools. The ordering of my PATH will ensure that the 'cpan' command will not touch these installs (unless I change some other config variables first). I will only use the version in /usr/local for my own development, and manage its modules via CPAN directly.

(I haven't installed fink on my new system yet, but if I do, I will manage it identically to the macports perl: keep it later in my PATH than /usr/local/bin, and it will only get updated via installation dependencies.)

Regarding the default system Perl breaking things, see

Ether
+1 for good x-refs.
Jonathan Leffler
+8  A: 
John Siracusa
+1 : BTW, This excellent advice applies to ALL computer languages that come pre-installed on ALL operating systems. Never mess with them manually and always leave to OS's own packaging updates/patches.
draegtun
+1  A: 

The default Perl coming with Snow Leopard is pretty good. It's v5.10.0. I've actually had less problems with it than the macports one (for DBI for example). I'd recommend sticking with the default Perl (and all other default programs) until you bump into something that doesn't suit you. No need to bother with newer version just for the sake of newer versions...

Zoran Simic
There are some incompatibilities between 5.10.0 and 5.10.1 (e.g. in the syntax for smart matching), so there are definite advantages to upgrading.
Ether
One of the advantages to upgrading is a smart match operator that works.
brian d foy
+2  A: 

I just started using using local::lib with the system perl. So far, I'm pretty happy with it.

Follow the bootstrap instructions, then set environment variables to match local::lib output in /Users/blah/.MacOSX/environment.plist.

daotoad