All about CPAN
Got a complex task to do? The chances are there's a module that already does it.
CPAN, the Comprehensive Perl Archive Network, is the number one source for pre-packaged modules in the Perl world. Some modules are written in Perl, but others are linked to C or C++ code for high performance or interfaces to other systems.
You can find out about CPAN on the web at www.perl.com/CPAN/, which will direct you to the nearest CPAN mirror site. CPAN's top level contains various roadmap and README files. Below it are directories holding ports (Perl ported to run on different operating systems), scripts (mostly older Perl scripts), the current Perl source code, and modules. The modules directory tree is deep -- you can descend different sub-trees to locate modules by name, by general category and by author.
Well-written modules are installed using the UNIX tool make; a Makefile (make script) is generated for your system by running a Perl script called Makefile.PL which is present in the module archive when you unpack it. (Note that most modules are packaged as gzip-compressed UNIX tar archives -- file suffix .tar.gz -- and not as DOS/Windows ZIP archives, although WinZip can cope with this format.)
Perl on Windows comes with a variety of pre-installed modules, and ActiveState provide a packaging tool for installing or building modules in a form useful for Windows set-ups; because Perl has historically been a UNIX-based language, many CPAN modules won't install cleanly on Windows.
Luckily the ActiveState Perl comes with the Perl Package Manager (PPM), specifically designed to download and install modules. See 'Using PPM' in the ActivePerl Components documentation.
If that just isn't good enough for you, see the documentation on compiling the CPAN modules for Windows in the ActiveState documentation. The information you need is in the Modules and Samples FAQ, under 'How do I use modules from CPAN?' The various tools you'll need are on this CD, in the \handson\files\perl\wintools folder.
For Linux users, the easiest way to install a module on Linux is to use the CPAN module, which comes with recent versions of Perl (5.004 and higher). Run it like this:
perl -MCPAN -e shell
The -M flag means "load the following named module"; the -e flag means "execute the following command", in this case "shell", which is exported by the module CPAN. CPAN.pm's shell will prompt you for some setup information -- though you can try letting it autoconfigure -- then will download the index files and let you search for and install modules.
Because modules provide reusable chunks of code, it should be no surprise that some modules depend on other modules. CPAN.pm is smart enough to automatically detect and install these dependencies first, before working on the module you asked for.