Apple's OS X 10.3 operating system (also known as Panther) is based on Unix and comes with a recent version of Perl (5.8.1) already installed. While that's enough to execute many Perl programs, there are common libraries that many Perl programs need that are not part of this default installation. There are a few simple things you have to do to get those libraries when you need them.
Note: There is additional information at the bottom of this page that may be helpful for later versions of OS X.
There is a large collection of Perl software and documentation on the Internet called CPAN (the Comprehensive Perl Archive Network, www.cpan.org). There is an easy to use Perl program that comes pre-installed on Panther that can download and install Perl software for you called CPAN.pm. However, to use CPAN.pm, you need certain other files and programs installed on your system that are not installed by default when you get Panther. Those files and programs, though, are included with Panther ready to be installed with the right command. Once you have installed them, you can run CPAN.pm and need not install them again. If your disk already has the folder Developer at top level (along with Library, System, Users, etc.) then the Developer Tools have already been installed.
The files and programs that CPAN.pm needs are part of the Developer Tools that come with new Macintoshes that ship with OS X 10.3. (It is also on various CDs and available online from Apple Developer Connection.) Installing these tools gives you much more than is needed by Perl, but that is how Apple does it.
To install the Developer Tools on a new Mac that comes with OS X 10.3 do the following: In the Finder, go to Applications. In the Applications folder you will find the Installers folder. In there is the Developer Tools folder. Finally, in the Developer Tools folder there is a file named Developer.mpkg. Double clicking on that file will install all the files needed (and much more). It takes a few minutes to execute and uses up lots of disk.
On a Mac that had OS X 10.3 installed over an earlier version of the OS (and perhaps other cases), you may need to install the Developers Tools from the CDROM or download it from Apple's web site.
Once you have the Developer Tools installed, you can now run CPAN.pm to download the latest versions of any needed CPAN library software.
To run CPAN.pm, you first need to use a Terminal window. You will find the Terminal application in the Applications/Utilities folder. When run, it opens up a pretty traditional Unix command line interface window running a shell program. (You can customize the look to your heart's content with options, of course.) The Terminal window, by default, prompts with the path of your current working directory and your login name.
To run CPAN.pm enter the following at the prompt (case matters):
sudo perl -MCPAN -eshell
The sudo part of the command lets authorized users run a command as the root user to have permission to do the installs needed. The sudo command logs these commands in the /var/log/system.log file by default. (You can learn more about sudo by looking at its man page with "man sudo".) If needed, the sudo command will then prompt you for your user password. You must have admin privileges (the first user set in OS X is such a user) or have your user name on a special list (that defaults to only admin users).
The rest of the command tells the Perl system to run CPAN.pm.
The first time you run CPAN.pm it will prompt you for information to set its configuration file. For almost all of the questions you can just press Return to take the default suggestion. It will ask for many settings. If the one asking you for the location of the make program (after about a dozen other questions) does not provide a non-blank default (such as "[/usr/bin/make"], you have not installed the needed Developer Tools.
Eventually it will ask you to choose an Internet address from which to download CPAN files. It will ask for a Continent (e.g., 5 for North America), etc. Eventually you will get a list of FTP addresses. Choose a couple, for example in the USA, 11 and 24 for NASA and Duke University.
Finally, it will write out the settings to the file /System/Library/Perl/5.8.1/CPAN/Config.pm (where they may be edited in the future, or you can delete the file and go through the questions again).
After setting the configuration, and any subsequent times you run CPAN.pm, you will see the CPAN shell and see a prompt, "cpan>".
To install LWP::UserAgent, type the following after the cpan prompt:
install LWP::UserAgent
The CPAN.pm program will download the software and check for dependencies on other pieces of software. Many of them will already be on your system, but some may not. For example, the URI and HTML::Parser software is not on OS X by default. The CPAN.pm program will ask you if it should add them to the queue of modules it is processing. You should take the default (yes) be pressing Return for this and other prompts during this process. (There may be one about decoding Unicode entities.) When done you will see a line with "/usr/bin/make install OK" and then another "cpan>" prompt, waiting for new commands. You can use the "q" command to quit.
That is all that is needed to prepare your computer to run our Perl programs.
There have been reports that you may need to do additional things to get Perl setup correctly with later versions of OS X. You may have to install xtools and not just developer tools. Also, instead of doing an "install", you may need to use "force install". You will know that the normal procedure above wasn't sufficient if you get messages about missing modules or being unable to "make" LWP, etc.