integer | lib | sigtrap | strict | subs | vars |
A pragma is a way to tell a compiler (or interpreter) to change its behavior. In some cases this is a command and in others it is just a suggestion. In Perl these take the form of a use declaration. Here is a list of the pragmas alphabetically with a description of their behavior.
By default, Perl assumes that it must do most of its arithmetic in floating
point. This pragma tells Perl it is ok to use integer operations from here
to the end of the enclosing block. An inner block may countermand this by
saying:
no integer;
which last till the end of that inner block.
Perl searches for modules in a standard list of locations.
To add to that list at compile time put:
use lib "/my/own/lib/directory";
This pragma has global effect (not limited to current block).
use sigtrap
use strict
To encouage or force the use of lexical variables, say:
use strict 'vars';
which causes Perl to require that any variable reference by a
lexical variable, or a
variable fully qualified with a package name. A fatal error
occurs otherwise. An inner block may countermand with:
no strict 'vars';
One can also turn on strict checking of symbolic references and
barewords with this pragma, or all three with just:
use strict;
use subs
Subroutines that are imported from other modules
have special privileges in Perl. One can confer these
privileges on your own subroutines with:
use subs qw(&read &write);
This pragma has global effect (not limited to current block).
use vars
Variables that are imported from other modules have special
privileges in Perl. They are exempt from use strict 'vars'
,
since importation is a form of declaration. One can confer these
privileges on your own variables with:
use vars qw($bee $bob @bong);
This pragma has global effect (not limited to current block).