strict - Restrict Unsafe Constructs

use strict; # apply all possible restrictions use strict 'vars'; # restrict unsafe use of variables for rest of block use strict 'refs'; # restrict unsafe use of references for rest of block use strict 'subs'; # restrict unsafe use of barewords for rest of block no strict 'vars'; # relax restrictions on variables for rest of block no strict 'refs'; # relax restrictions on references for rest of block no strict 'subs'; # relax restrictions on barewords for rest of block

If no import list is given to use strict, all possible restrictions upon unsafe Perl constructs are imposed. (This is the safest mode to operate in, but is sometimes too strict for casual developing.) Currently, there are three possible things to be strict about: refs, vars, and subs.

In all cases the restrictions apply only until the end of the immediately enclosing block.

The no strict 'vars' statement negates any preceding use strict vars for the remainder of the innermost enclosing block. Likewise, no strict 'refs' negates any preceding invocation of use strict refs, and no strict 'subs' negates use strict 'subs'.

The arguments to use strict are sometimes given as barewords - that is, without surrounding quotes. Be aware, however, that the following sequence will not work:

use strict; # or just: use strict subs; ... no strict subs; # WRONG! Should be: no strict 'subs'; ...

The problem here is that giving subs as a bareword is no longer allowed after the use strict statement. :-)