The best thing about Perl is CPAN. CPAN is the C omprehensive P erl A rchive N etwork. In short, it's where you go to find Perl software. Perl software is distributed as Perl modules. There's nothing particularly special about Perl modules. They're written in plain text files which you can load up into your favourite text editor to see how they work. Perl modules typically have a .pm file extension instead of .pl and they're usually distributed in zipped bundles that come with a .tar.gz file extension.

Some Perl modules use extensions written in the C programming language. C works at a lower level than Perl so it typically runs faster and allows module authors to do the kind of things that can't be done in Perl alone. In order to use any modules with C extensions, you'll need to have a C compiler installed on your machine. A compiler is a little like an interpreter, except that it does more work up front (i.e. when you install a module) so that it runs faster when you come to use it. Apple provide a C compiler (GCC) as part of the Xcode developer tools. You can install these from your Mac OSX installation disks, or by downloading from the Apple Developer Connection web site.

You can unpack and install Perl modules manually, but most people these days use the CPAN module to do it for them. This should already be installed on your Mac. From the Terminal command line, type sudo cpan to start it running. The sudo part of the command indicates that you want to run the cpan program as the administrator or "super user" (sudo stands for s uper u ser do ). If you're not an administrator of the machine you're using then you'll have to go and find the administrator and be nice to him or her. If you are then type your password (the one you use to login to your Mac) and hit return.

The first time you run the cpan program it will ask you a bunch of questions so that it can configure itself. Answer the questions as best you can (just hit RETURN if you're not sure) and then you should be greeted with a cpan[1]> prompt.

$ sudo cpan ...a few questions later... cpan[1]>

Now that CPAN is configured, you can use it to install Perl modules. Let's start by installing the DateTime module. You can probably guess what this module is used for!

cpan[1]> install DateTime ...lots of output... All tests successful. Files=43, Tests=3277, 13 wallclock secs ( 0.51 usr 0.20 sys + 10.70 cusr 0.73 csys = 12.14 CPU) Result: PASS DROLSKY/DateTime-0.4501.tar.gz /usr/bin/make test -- OK Running make install Prepending /Users/abw/.cpan/build/DateTime-0.4501-...blah blah blah... Password: enter your password here ...some more output... Appending installation info to /System/Library/Perl/5.8.8/...blah blah blah... DROLSKY/DateTime-0.4501.tar.gz sudo make install -- OK cpan[4]>

Assuming that all the pre-installation tests pass, the CPAN module will automatically run the sudo make install command to install the module. At this point sudo will prompt you to enter your password to become the super-user. If you're not an administrator of the machine you're using then you'll have to go and find the administrator and be nice to him or her.

If the pre-installation tests don't pass then you have two choices. Either don't use the module, or install it anyway and hope for the best. It's not uncommon for modules to fail a few minor tests, particularly if the author wrote it on a different platform to yours and didn't account for minor differences in filenames, date formats, locales, or any of the other messy things that make it difficult to write portable code that works everywhere. You can force install a module if you want to use it regardless of any test failures.

cpan[2]> force install SomeDodgyModule

If you do encounter problems then please report them (or see if someone else has already reported them) at http://rt.cpan.org/.