Chapter 32. Standard Modules
Contents:
Benchmark
Carp
CGI
CGI::Carp
Class::Struct
Config
CPAN
Cwd
Data::Dumper
DB_File
Dumpvalue
English
Errno
Exporter
Fatal
Fcntl
File::Basename
File::Compare
File::Copy
File::Find
File::Glob
File::Spec
File::stat
File::Temp
FileHandle
Getopt::Long
Getopt::Std
IO::Socket
IPC::Open2
IPC::Open3
Math::BigInt
Math::Complex
Math::Trig
Net::hostent
POSIX
Safe
Socket
Symbol
Sys::Hostname
Sys::Syslog
Term::Cap
Text::Wrap
Time::Local
Time::localtime
User::grent
User::pwent
The previous edition of this book included comprehensive, definitive
coverage for all modules that were part of the standard Perl
distribution. But if we did that again now, you'd pay twice what
you're paying for this book, not to mention what you'd have to pay the
chiropractor after trying to carry the book home. Over the last few
years, more and more modules have come bundled standard; we're up to
around two hundred of them right now. Some of these, such as
CGI, have remarkably extensive documentation in
their own right. And if you're using ActiveState's distribution of
Perl, your standard library is even more luxed out.So instead, we provide a complete listing of the standard modules,
sorted by type, along with a brief description of what each module
does. Then we cherry pick a few of our favorite modules by providing
examples of typical uses, followed by a short description of how they
work, just to give you a taste of using them. The descriptions are
suggestive rather than comprehensive, and virtually all the modules
have features beyond those shown. However, complete documentation for
all standard modules is included with every Perl distribution, so you
can just look up the details on your own system using the
perldoc program, your system's
man(1) command, or your favorite
browser. See the section "Online Documentation" in the Preface. Ask
your Local Expert if you can't find the docs, because they're almost
certainly installed somewhere on your system.
Even if they're not, you can always read the pod docs directly from
the modules themselves, because all module docs come embedded in their
corresponding module (.pm) files, and pod was
designed to be somewhat readable. (Unlike, say, HTML.)
32.1. Listings by Type
Normal module names begin with an uppercase letter. Lowercase names
indicate pragmas that you'll find documented in Chapter 31, "Pragmatic Modules", rather than in this chapter.
32.1.1. Data Types
These modules extend Perl's type system (or lack thereof) in various
ways.
32.1.2. String Processing, Language Text Processing, Parsing, and Searching
These modules do things with (or to) text.
32.1.3. Option, Argument, Parameter, and Configuration
File Processing
These modules process your command line.
Module | Description |
---|---|
Getopt::Long | Process extended command-line options in long form (--xxx) |
Getopt::Std | Process single-character switches with switch clustering (-xyz) |
32.1.4. Filenames, Filesystems, and File Locking
These modules provide cross-platform methods of file access.
32.1.5. Filehandle, Directory Handle, and
Stream I/O Utilities
These modules provide object-oriented file, directory, and IPC access.
32.1.6. Internationalization and Locale
These modules help you perform Un-American Activities.
32.1.7. Operating System Interfaces
These modules tweak your interface to the operating system.
32.1.8. Networking and Interprocess Communication
These modules provide abstract interfaces around the basic
interfaces we wrote about in Chapter 16, "Interprocess Communication".
32.1.9. World Wide Web
These modules interface to the WWW. You may have heard of it.
32.1.10. DBM Interfaces
These modules load various database management libraries.
32.1.11. User Interfaces
These modules provide a decent OS CLI I/O API, ASAP.
Module | Description |
---|---|
Term::Cap | Use the termcap(3) library |
Term::Complete | Do programmable command completion on word lists |
Term::ReadLine | Use any of several readline packages |
32.1.12. Authentication, Security, and Encryption
These modules work with sandboxes.
32.1.13. Perl Language Extensions and Internals
(Not to be confused with Intentions and Externals.)
Module | Description |
---|---|
attributes | Get or set subroutine or variable attributes |
attrs | Get or set subroutine or variable attributes (obsolete) |
base | Establish inheritance of base class at compile time |
Data::Dumper | Serialize Perl data structures |
DB | Access the Perl debugger's experimental API |
Devel::DProf | Profile a Perl program's execution |
Devel::Peek | Load data debugging tools for XS programmers |
diagnostics | Force verbose warnings and suppress duplicates |
Dumpvalue | Provide screen dump of data |
English | Use longer variable names for built-in punctuation variables |
Env | Access environment variables in %ENV as regular scalars |
Errno | Load the C library's errno.h definitions and tie the %! variable |
Fatal | Replace built-ins with versions that raise exceptions on failure |
fields | Declare compile-time verified access to a class's data attributes |
less | Request less of something from Perl (unimplemented) |
re | Alter default regular expression behavior |
strict | Restrict sloppy constructs |
subs | Predeclare the subroutine names in current the package |
vars | Predeclare global variables (obsolete--see our in Chapter 29, "Functions") |
32.1.14. Convenient Classes
These modules provide base classes and other conveniences.
32.1.15. Warnings and Exceptions
What to do when things go rwong.
Module | Description |
---|---|
Carp | Provide routines that warn and die from the perspective of the caller |
warnings | Control warnings within the lexical scope |
32.1.16. Documentation Support
And there's an awful lot of documentation to support.
32.1.17. Module Installation Support
These modules help other modules jump through various hoops.
32.1.18. Development Support
These modules are for timing and testing, to see how much faster
and cleaner your code doesn't run anymore.
Module | Description |
---|---|
Benchmark | Compare running times of alternate code versions |
Test | Use a simple framework for writing test scripts |
Test::Harness | Run standard test scripts with statistics |
32.1.19. Perl Compiler and Code Generator
These modules support various backend code generators for Perl.
32.1.20. Microsoft-Related Modules
If you got the Perl distribution for Microsoft systems from
ActiveState, you already have the following Microsoft-only modules
included for you. If you just grabbed the standard source distribution
(maybe you want to build it under the Cygwin Unix-emulation environment) but you're running on Wintel, you can get all of these modules
from CPAN.