I wanted to install Perl 5.8.3 and Perl/Tk under Panther, and I had a hell of a time trying to get this to work, simply because there isn’t a good HOWTO or anything that I was able to find. So here are the steps I had to take, for future reference:
note: where you see “%” and “cpan>”, these indicate input at a prompt in the UNIX shell or in the cpan utility. The portion of the line to be typed is after the “%” or “cpan>”. You would be surprised at how often this confuses newbies, but I can understand why.
You may want to remove fink, if you have it installed. Follow the directions in this earlier post by John; you may have to prepend sudo to some of those commands.
Install Apple’s X11 and, from the developer CD or from Apple’s developer site, install the X11SDK — this is necessary because Apple only provides the libraries with their X11 distribution, but none of the header files. DON’T download the X11 source. I made that mistake and it wasn’t helpful.
Download the Perl source from www.perl.org or whereever. I used 5.8.3, but most 5.8.x versions should be fine — perhaps even earlier versions might work?
Un-tgz the source to the directory of your choice, then in the terminal run the configure script like so:
% sh ./Configure -des -Duseshrplib -Dprefix=directory to install to
**This is really important.** Make sure the directory you install to has nothing else in it. I pointed my -Dprefix= to /opt, and then once I was certain everything was working, I moved everything from /opt to /usr and it worked fine.
After running Configure, of course you want to run % make && make test && sudo make install.
Test your new Perl to make sure that it works, i.e. if you installed to /opt, run
% /opt/bin/perl -e 'print "hello, world!\n";'
The make test directive a few lines above runs a more thorough test suite — we are just checking to make sure Perl is where you think it is.
Change directories to wherever you installed perl; **THIS IS UBER-IMPORTANT!** Make ABSOLUTELY CERTAIN that you are in the correct directory. For example, if I ran Configure with the option -Dprefix=/opt, then I would now change directories by typing:
% cd /opt
If you don’t change to the correct directory, the mv command ahead could seriously cramp your style. Once you are in the correct directory, the output of % ls should list just 3 directories: bin, lib, and man (I think.) Run this command next:
% sudo mv * /usr
That will overwrite your old perl installation in a fairly brute-force manner. It’s ugly, but it works. Did I mention that you should know a little about what you are doing before you attempt this? Well I meant to.
Now you have Perl and X11 installed, time to set up Perl/Tk! What you should do now is navigate to Applications->Utilities under the Finder and execute X11. This will open up a terminal titled “xterm”. **This is also really important** You MUST have X11 running during the Tk install process — it runs many tests that depend on X11 running, and it will fail to install if you try to do this without having X11 running.
In the xterm, execute
% sudo cpan
If this is your first time running cpan, it will want you to set up a number of things. You can accept the defaults on most of the options, but you really should choose a different mirror for downloading Perl modules from, since the main repository is pretty regularly hosed these days.
Once you have cpan set up, you should run:
cpan> install Tk
A lengthy download, compile, and install process will follow, and while the installer is testing the Tk stuff, it will pop up multiple windows in the upper left corner of the display — this is normal. If all things went well, you should have Tk installed in about 30 minutes to an hour.
To test Tk, try running % perl -e 'use Tk;' and if it gives you an error, then you don’t have Tk installed. If it doesn’t do anything at all, then chances are you have Tk installed properly. Now do a real test by writing something useful that uses Tk. See? That wasn’t so bad.
I hope that this is helpful to anyone who may read it. Comments, complaints, whatever — they are all appreciated.
–edit: moved body back into main post so that search engines will see more data.