You are on page 1of 1

use strict

Warnings and taint are two excellent tools for preventing your programs from doing bad things. If you want to go further, Perl offers use strict. These two simple words can be put at the beginning of any program:
#!/usr/local/bin/perl -wT use strict;

A command like use strict is called a pragma. Pragmas are instructions to the Perl interpreter to do something special when it runs your program. use strict does two things that make it harder to write bad software: It makes you declare all your variables (``strict vars''), and it makes it harder for Perl to mistake your intentions when you are using subs (``strict subs''). If you only want to use one or two types of strictness in your program, you can list them in the use strict pragma, or you can use a special no strict pragma to turn off any or all of the strictness you enabled earlier.
use strict 'vars'; no strict 'vars'; use strict 'subs'; below). no strict; strict. # Turn it off. Turn it all off. Go away, # We want to require variables to be declared # We'll go back to normal variable rules now # We want Perl to distrust barewords (see

(There's actually a third type of strictness - strict refs - which prevents you from using symbolic references. Since we haven't really dealt with references, we'll concentrate on the other two types of strictness.)

You might also like