Perl on OpenSolaris
fmw | November 28, 2009The version of perl installed by default (2009.06) is 5.8.4. We’d like it to be
- More recent and
- Compiled locally.
The reason it needs to be compiled locally arises if you want to use modules from CPAN which contain compiled code. The assumption is that the installed perl was built with Sun’s c compiler whereas modules on CPAN are more than likely compiled with gcc.
So we need a C tool chain first.
pkg install gcc-dev
Knock up a quick Hello World source file.
#include <stdio.h> int main(void) { printf("Hello World!n"); return 0; } gcc test.c -o test.bin # ./test.bin Hello World!
We’re in business.
Getting Perl.
I found it here:
http://www.cpan.org/src/README.html
And used wget to retrieve
http://www.cpan.org/src/perl-5.10.1.tar.gz
gunzipped and de-tar’d into a directory. (The tar in FreeBSD is more convenient – it has a -z option to do the gunzipping).
Ooh! There’s a README.solaris file. Better have a look.
http://search.cpan.org/~dapm/perl-5.10.1/README.solaris
The configure command needs to know we’re going to build perl with gcc
sh Configure -Dcc=gcc
Operating system name? [solaris]
Operating system version? [2.11] 2.11
Pathname where the public executables will reside? (~name ok) [/opt/bin]
Directory /opt/bin doesn't exist. Use that name anyway? [n] !
sh-3.2# mkdir /opt/bin
sh-3.2#
make depend
make
make test
make install
Then I put the original perl aside
cd /usr/bin/
mv perl perl_original
ln -s /opt/bin/perl perl
perl –V
Then I noticed /opt/bin/cpan, so I ran it (a bit Alice In Wonderland, I suppose)
Answered default to all questions.
Set CPAN mirrors to
http://mirror.ox.ac.uk/sites/www.cpan.org/
ftp://ftp.demon.co.uk/pub/CPAN/
m Date::Calc
(gets information about a module)
install Date::Calc
Easy!
Saw messages flashing past like "LWP not present" so I installed it too and now it announces that it’s using LWP to fetch.

