How to switch between versions of Perl 5.8 and 5.10 on Mac OS X 10.6 Server and using Apache2

2.5k views Asked by At

The new Mac Mini Server comes with OS X 10.6 and natively supports (comes with) two versions of Perl and Apple has included these by default for good reason.

These can be found under the following directories: /Library/Perl/5.8.9 and /Library/Perl/5.10.0 I also found under /Library/Perl/Updates/5.8.9 and /Library/Perl/Updates/5.10.0.

I found that I can successfully switch between perl 5.8.9 and and 5.10.0 at the console level by using Apples suggested "defaults write" command using the terminal.

For example since OS X Server 10.6 comes delivered with the default set to 5.10.0 I have successfully used the following two commands to switch to perl 5.8.9 using 32 bit and everything works as expected at the console level.

sudo defaults write /Library/Preferences/com.apple.versioner.perl Version 5.8.9
sudo defaults write com.apple.versioner.perl Prefer-32-Bit -bool yes

I was successful at installing the following desired Perl modules using the CPAN shell like so for the default version of perl 5.10.0:

sudo perl -eshell -MCPAN
install DBI
install CGI
install HTML::Template
install DBD::Pg

I used DBD:Pg to connect to the PostgreSQL database and that seems to work fine too.

However, when I attempt to switch to Perl 5.8.9 from 5.10.0 I get the following Error in Apache when attempting to use the same Perl Code.

Server error!
  The server encountered an internal error and was unable to complete your request.
  Error message:
  Premature end of script headers: login.pl
  If you think this is a server error, please contact the webmaster.
Error 500
  192.168.2.100
  Mon Aug 9 12:10:09 2010
  APACHE/2.2.14(UNIX)mod_ssl/2.2.14 OpenSSL/0.9.81

I then decided that it might be a good idea go through the "sudo perl -eshell -MCPAN" stuff again after I switched to perl 5.8.9 by using the "default write" command however that didn't seem to help.

Does anyone have any ideas why I am getting these results? Do you have any suggestions on a better approach without using precompiled binaries as I don't have any problem compiling from source code.

Thanks in advance.

DougPan

1

There are 1 answers

1
xenoterracide On

Tried App::perlbrew and local::lib? The first is designed for managing multiple installations of perl (though don't know if it can do existing ones) the second is for having ... more special cases of libraries installed. It would make it very easy to have 1 set of cpan libraries for each perl version and each app if you needed.