A Perl pragma to restrict unsafe constructs.
Typically, Perl is fairly relaxed of what you can do; All global variables are global and get created automatically, for example.
Thus, the use of strict pragma - "
use strict;", along with the -w interpreter command line parameter or the
warnings pragma, is very useful to catch "bad habits" and typos in variable names.
The pragma comes in three variants. Typically all are in use at once, but you can enable disable these at will with
use strict "this";,
no strict "that"; - or just use
use strict; to use all three by default.
use strict "vars";
- Gives runtime errors if variables not declared previously are used. Use something like
use vars pragma,
my, or such to declare them.
use strict "refs";
- Gives runtime errors if symbolic references are used.
use strict "subs";
- Gives runtime errors if you use a bareword that's not a subroutine, unless it's clearly a hash key or similiar.