Getting and Installing Modules

As you’ll see when you look at the lists of modules and their authors on CPAN, many users have made their modules freely available. If you find an interesting problem and are thinking of writing a module to solve it, check the modules directory on CPAN first to see if there is a module there that you can use. The chances are good that there is a module that does what you need, or perhaps one that you can extend, rather than starting from scratch.[3]

Before you download a module, you might also check your system to see if it’s already installed. The following command searches the libraries in the @INC array and prints the names of all modules it finds:

find `perl -e 'print "@INC"'` -name '*.pm' -print

[3] If you are interested in writing and contributing modules, there are several good starting points for learning to do so—see the perlmodlib manpage, the “Perl 5 Module List,” and the “Perl Authors Upload Server” (http://www.perl.com/CPAN/modules/04pause.html).

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.