They work somewhat like pragmas in that they tend to affect the compilation of your program, and thus will usually work well only when used within a use
, or no
. Most of these are lexically scoped, so an inner BLOCK may countermand any of these by saying:
no integer;
no strict 'refs';
which lasts until the end of that BLOCK.
Unlike the pragmas that effect the $^H
hints variable, the use vars
and use subs
declarations are not BLOCK-scoped. They allow you to predeclare a variables or subroutines within a particular file rather than just a block. Such declarations are effective for the entire file for which they were declared. You cannot rescind them with no vars
or no subs
.
The following pragmas are defined (and have their own documentation).
"use autouse MODULE => qw(sub1 sub2 sub3)" - Defers require MODULE
until someone calls one of the specified subroutines (which must be exported by MODULE). This pragma should be used with caution, and only when necessary.
blib - manipulate @INC at compile time to use MakeMaker's uninstalled version of a package
diagnostics - force verbose warning diagnostics
integer - compute arithmetic in integer instead of double
less - request less of something from the compiler
lib - manipulate @INC at compile time
locale - use or ignore current locale for builtin operations (see perllocale)
ops - restrict named opcodes when compiling or running Perl code
overload - overload basic Perl operations
re - alter behaviour of regular expressions
sigtrap - enable simple signal handling
strict - restrict unsafe constructs
subs - predeclare sub names
vmsish - adopt certain VMS-specific behaviors
vars - predeclare global variable names
Standard, bundled modules are all expected to behave in a well-defined manner with respect to namespace pollution because they use the Exporter module. See their own documentation for details.
AnyDBM_File - provide framework for multiple DBMs
AutoLoader - load functions only on demand
AutoSplit - split a package for autoloading
Benchmark - benchmark running times of code
CPAN - interface to Comprehensive Perl Archive Network
CPAN::FirstTime - create a CPAN configuration file
CPAN::Nox - run CPAN while avoiding compiled extensions
Carp - warn of errors (from perspective of caller)
Class::Struct - declare struct-like datatypes
Config - access Perl configuration information
Cwd - get pathname of current working directory
DB_File - access to Berkeley DB
Devel::SelfStubber - generate stubs for a SelfLoading module
DirHandle - supply object methods for directory handles
DynaLoader - dynamically load C libraries into Perl code
English - use nice English (or awk) names for ugly punctuation variables
Env - import environment variables
Exporter - implements default import method for modules
ExtUtils::Embed - utilities for embedding Perl in C/C++ applications
ExtUtils::Install - install files from here to there
ExtUtils::Liblist - determine libraries to use and how to use them
ExtUtils::MM_OS2 - methods to override Unix behaviour in ExtUtils::MakeMaker
ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
ExtUtils::MM_VMS - methods to override Unix behaviour in ExtUtils::MakeMaker
ExtUtils::MakeMaker - create an extension Makefile
ExtUtils::Manifest - utilities to write and check a MANIFEST file
ExtUtils::Mkbootstrap - make a bootstrap file for use by DynaLoader
ExtUtils::Mksymlists - write linker options files for dynamic extension
ExtUtils::testlib - add blib/* directories to @INC
Fatal - make errors in builtins or Perl functions fatal
Fcntl - load the C Fcntl.h defines
File::Basename - split a pathname into pieces
File::CheckTree - run many filetest checks on a tree
File::Compare - compare files or filehandles
File::Copy - copy files or filehandles
File::Find - traverse a file tree
File::Path - create or remove a series of directories
File::Spec - portably perform operations on file names
File::Spec::Functions - function call interface to File::Spec module
File::stat - by-name interface to Perl's builtin stat() functions
FileCache - keep more files open than the system permits
FileHandle - supply object methods for filehandles
FindBin - locate directory of original Perl script
GDBM_File - access to the gdbm library
Getopt::Long - extended processing of command line options
Getopt::Std - process single-character switches with switch clustering
I18N::Collate - compare 8-bit scalar data according to the current locale
IO - load various IO modules
IO::File - supply object methods for filehandles
IO::Handle - supply object methods for I/O handles
IO::Pipe - supply object methods for pipes
IO::Seekable - supply seek based methods for I/O objects
IO::Select - OO interface to the select system call
IO::Socket - object interface to socket communications
IPC::Open2 - open a process for both reading and writing
IPC::Open3 - open a process for reading, writing, and error handling
Math::BigFloat - arbitrary length float math package
Math::BigInt - arbitrary size integer math package
Math::Complex - complex numbers and associated mathematical functions
Math::Trig - simple interface to parts of Math::Complex for those who need trigonometric functions only for real numbers
NDBM_File - tied access to ndbm files
Net::Ping - Hello, anybody home?
Net::hostent - by-name interface to Perl's builtin gethost*() functions
Net::netent - by-name interface to Perl's builtin getnet*() functions
Net::protoent - by-name interface to Perl's builtin getproto*() functions
Net::servent - by-name interface to Perl's builtin getserv*() functions
Opcode - disable named opcodes when compiling or running Perl code
Pod::Text - convert POD data to formatted ASCII text
POSIX - interface to IEEE Standard 1003.1
SDBM_File - tied access to sdbm files
Safe - compile and execute code in restricted compartments
Search::Dict - search for key in dictionary file
SelectSaver - save and restore selected file handle
SelfLoader - load functions only on demand
Shell - run shell commands transparently within Perl
Socket - load the C socket.h defines and structure manipulators
Symbol - manipulate Perl symbols and their names
Sys::Hostname - try every conceivable way to get hostname
Sys::Syslog - interface to the Unix syslog(3) calls
Term::Cap - termcap interface
Term::Complete - word completion module
Term::ReadLine - interface to various readline
packages
Test::Harness - run Perl standard test scripts with statistics
Text::Abbrev - create an abbreviation table from a list
Text::ParseWords - parse text into an array of tokens
Text::Soundex - implementation of the Soundex Algorithm as described by Knuth
Text::Tabs - expand and unexpand tabs per the Unix expand(1) and unexpand(1)
Text::Wrap - line wrapping to form simple paragraphs
Tie::Hash - base class definitions for tied hashes
Tie::RefHash - base class definitions for tied hashes with references as keys
Tie::Scalar - base class definitions for tied scalars
Tie::SubstrHash - fixed-table-size, fixed-key-length hashing
Time::Local - efficiently compute time from local and GMT time
Time::gmtime - by-name interface to Perl's builtin gmtime() function
Time::localtime - by-name interface to Perl's builtin localtime() function
Time::tm - internal object used by Time::gmtime and Time::localtime
UNIVERSAL - base class for ALL classes (blessed references)
User::grent - by-name interface to Perl's builtin getgr*() functions
User::pwent - by-name interface to Perl's builtin getpw*() functions