Contents:
Beyond the Standard Library
Library Modules
This chapter describes the collection of Perl code that comes along with the Perl distribution. If you use this library and then share your program with others, they will not have to take special steps to execute the program, because the same library is available to Perl programs everywhere.
You'll save some time if you make the effort to get familiar with the standard library. There's no point in reinventing the wheel. You should be aware, however, that the library contains a wide range of material. While some modules may be extremely helpful, others may be completely irrelevant to your needs. For example, some are useful only if you are creating extensions to Perl. We offer below a rough classification of the library modules to aid you in browsing.
First, however, let's untangle some terminology:
A
package
is a simple namespace management device, allowing two
different parts of a Perl program to have a (different) variable
named
$fred
. These namespaces are managed with the
package
declaration, described in
Chapter 5,
Packages, Modules, and Object Classes
.
A library is a set of subroutines for a particular purpose. Often the library declares itself a separate package so that related variables and subroutines can be kept together, and so that they won't interfere with other variables in your program. Generally, a library is placed in a separate file, often ending in " .pl ", and then pulled into the main program via require . (This mechanism has largely been superseded by the module mechanism, so nowadays we often use the term "library" to talk about the whole system of modules that come with Perl. See the title of this chapter, for instance.)
A
module
is a library that conforms to specific conventions, allowing
the file to be brought in with a
use
directive at compile time.
Module filenames end in "
.pm
", because the
use
directive insists
on that. (It also translates the subpackage delimiter
::
to
whatever your subdirectory delimiter is; it is
/
on UNIX.)
Chapter 5
describes Perl modules in greater detail.
A pragma is a module that affects the compilation phase of your program as well as the execution phase. Think of them as hints to the compiler. Unlike modules, pragmas often (but not always) limit the scope of their effects to the innermost enclosing block of your program. The names of pragmas are by convention all lowercase.
For easy reference, this chapter is arranged alphabetically. If you wish to look something up by functional grouping, Tables 7-1 through 7-11 display an (admittedly arbitrary) listing of the modules and pragmas described in this chapter.
@INC
at compile time
If you don't find an entry in the standard library that fits your needs, it's still quite possible that someone has written code that will be useful to you. There are many superb library modules that are not included in the standard distribution, for various practical, political, and pathetic reasons. To find out what is available, you can look at the Comprehensive Perl Archive Network (CPAN). See the discussion of CPAN in the Preface.
Here are the major categories of modules available from CPAN:
Archiving and Compression
Authentication, Security and Encryption
Control Flow Utilities (callbacks, exceptions, and so on)
Data Types and Data Type Utilities
Database Interfaces
Development Support
Filehandle and Input/Output Stream Utilities
File Names, File Systems and File Locking
Images, Pixmap and Bitmap Manipulation, Drawing and Graphing
Interfaces to/Emulations of Other Programming Languages
Internationalization and Locale
Language Extensions and Documentation Tools
Mail and Usenet News
Miscellaneous Modules
Networking, Device Control (modems) and Inter-process Communication
Operating System Interfaces
Option, Argument, Parameter and Configuration File Processing
Server and Daemon Utilities
String Processing, Language Text Processing, Parsing and Searching
User Interfaces
World Wide Web, HTML, HTTP, CGI, MIME
Allow us again to reiterate once more that these things are in a state of flux, and you will certainly find more and better stuff on CPAN than we can possibly describe here. The Perl of Great Price has outgrown its oyster, so to speak, because Perl is truly a community effort these days - see John 14:12.
[ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ]