They work somewhat like compiler directives (pragmata) 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 them by saying:
no integer;
no strict 'refs';
no warnings;
which lasts until the end of that BLOCK.
Some pragmas are lexically scoped--typically those that affect the $^H
hints variable. Others affect the current package instead, like use vars
and use subs
, which 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).
attributes - Get/set subroutine or variable attributes
autouse - Postpone load of modules until a function is used
blib - Use MakeMaker's uninstalled version of a package
bytes - Force byte semantics rather than character semantics
charnames - Define character names for \N{named}
string literal escapes
deprecate - Perl pragma for deprecating the core version of a module
diagnostics - Produce verbose warning diagnostics
feature - Enable new features
filetest - Control the filetest permission operators
integer - Use integer arithmetic instead of floating point
less - Request less of something
locale - Use and avoid POSIX locales for built-in operations
mro - Method Resolution Order
open - Set default PerlIO layers for input and output
ops - Restrict unsafe operations when compiling
overload - Package for overloading Perl operations
overloading - Lexically control overloading
re - Alter regular expression behaviour
sigtrap - Enable simple signal handling
sort - Control sort() behaviour
strict - Restrict unsafe constructs
subs - Predeclare sub names
utf8 - Enable/disable UTF-8 (or UTF-EBCDIC) in source code
vars - Predeclare global variable names (obsolete)
version - Perl extension for Version Objects
vmsish - Control VMS-specific language features
warnings - Control optional warnings
warnings::register - Warnings import function
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.
It's possible that not all modules listed below are installed on your system. For example, the GDBM_File module will not be installed if you don't have the gdbm library.
AnyDBM_File - Provide framework for multiple DBMs
B - The Perl Compiler Backend
B::Concise - Walk Perl syntax tree, printing concise info about ops
B::Showlex - Show lexical variables used in functions or files
B::Terse - Walk Perl syntax tree, printing terse info about ops
B::Xref - Generates cross reference reports for Perl programs
Benchmark - Benchmark running times of Perl code
CORE - Pseudo-namespace for Perl's core routines
Carp - Warn of errors (from perspective of caller)
Class::Struct - Declare struct-like datatypes as Perl classes
Config - Access Perl configuration information
DB - Programmatic interface to the Perl debugging API
DBM_Filter - Filter DBM keys/values
DBM_Filter::compress - Filter for DBM_Filter
DBM_Filter::encode - Filter for DBM_Filter
DBM_Filter::int32 - Filter for DBM_Filter
DBM_Filter::null - Filter for DBM_Filter
DBM_Filter::utf8 - Filter for DBM_Filter
Devel::DProf - A Perl code profiler
Devel::Peek - A data debugging tool for the XS programmer
Devel::SelfStubber - Generate stubs for a SelfLoading module
DirHandle - Supply object methods for directory handles
Dumpvalue - Provides screen dump of Perl data.
DynaLoader - Dynamically load C libraries into Perl code
English - Use nice English (or awk) names for ugly punctuation variables
Env - Perl module that imports environment variables as scalars or arrays
Errno - System errno constants
Exporter - Implements default import method for modules
Exporter::Heavy - Exporter guts
ExtUtils::Embed - Utilities for embedding Perl in C/C++ applications
ExtUtils::XSSymSet - Keep sets of symbol names palatable to the VMS linker
Fcntl - Load the C Fcntl.h defines
File::Basename - Parse file paths into directory, filename and suffix.
File::CheckTree - Run many filetest checks on a tree
File::Compare - Compare files or filehandles
File::Copy - Copy files or filehandles
File::DosGlob - DOS like globbing and then some
File::Find - Traverse a directory tree.
File::Glob - Perl extension for BSD glob routine
File::stat - By-name interface to Perl's built-in 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 - Perl5 access to the gdbm library.
Getopt::Std - Process single-character switches with switch clustering
Hash::Util - A selection of general-utility hash subroutines
Hash::Util::FieldHash - Support for Inside-Out Classes
I18N::Collate - Compare 8-bit scalar data according to the current locale
I18N::Langinfo - Query locale information
IPC::Open2 - Open a process for both reading and writing using open2()
IPC::Open3 - Open a process for reading, writing, and error handling using open3()
NDBM_File - Tied access to ndbm files
Net::hostent - By-name interface to Perl's built-in gethost*() functions
Net::netent - By-name interface to Perl's built-in getnet*() functions
Net::protoent - By-name interface to Perl's built-in getproto*() functions
Net::servent - By-name interface to Perl's built-in getserv*() functions
O - Generic interface to Perl Compiler backends
ODBM_File - Tied access to odbm files
Opcode - Disable named opcodes when compiling perl code
POSIX - Perl interface to IEEE Std 1003.1
PerlIO - On demand loader for PerlIO layers and root of PerlIO::* name space
PerlIO::encoding - Encoding layer
PerlIO::scalar - In-memory IO, scalar IO
PerlIO::via - Helper class for PerlIO layers implemented in perl
Pod::Functions - Group Perl's functions a la perlfunc.pod
Pod::Html - Module to convert pod files to HTML
SDBM_File - Tied access to sdbm files
Search::Dict - Search for key in dictionary file
SelectSaver - Save and restore selected file handle
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
Term::Complete - Perl word completion module
Term::ReadLine - Perl interface to various readline
packages.
Text::Abbrev - Create an abbreviation table from a list
Thread - Manipulate threads in Perl (for old code only)
Tie::Array - Base class for tied arrays
Tie::Handle - Base class definitions for tied handles
Tie::Hash - Base class definitions for tied hashes
Tie::Hash::NamedCapture - Named regexp capture buffers
Tie::Memoize - Add data to hash when needed
Tie::Scalar - Base class definitions for tied scalars
Tie::StdHandle - Base class definitions for tied handles
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 built-in gmtime() function
Time::localtime - By-name interface to Perl's built-in localtime() function
Time::tm - Internal object used by Time::gmtime and Time::localtime
UNIVERSAL - Base class for ALL classes (blessed references)
Unicode::UCD - Unicode character database
User::grent - By-name interface to Perl's built-in getgr*() functions
User::pwent - By-name interface to Perl's built-in getpw*() functions
VMS::DCLsym - Perl extension to manipulate DCL symbols
VMS::Stdio - Standard I/O functions via VMS extensions
Win32CORE - Win32 CORE function stubs
XS::APItest - Test the perl C API
XS::APItest::KeywordRPN - Write arithmetic expressions in RPN
XS::Typemap - Module to test the XS typemaps distributed with perl
version::Internals - Perl extension for Version Objects