Perl tends to be a pretty permissive language. But maybe you want
Perl to impose a little discipline; that can be arranged with the
use strict
pragma.
Why would this be important? Well, imagine that you're
composing your program, and you type a line like this one:
$bamm_bamm = 3; # Perl creates that variable automatically
Now, you keep typing for a while. After that line has scrolled off
the top of the screen, you type this line to increment the variable:
$bammbamm += 1; # Oops!
If you add use strict to an already-written
program, you'll generally get a flood of warning messages, so
it's better to use it from the start, when it's needed.
Most people recommend that programs that are longer than a screenful
of text generally need use strict. And we agree.
From here on, most (but not all) of our examples will be written as
if use strict is in effect, even where we
don't show it. That is, we'll generally declare variables
with my where it's appropriate. But, even
though we don't always do so here, we encourage you to include
use strict in your programs as often as possible.
 |  |  |
4.9. Notes on Lexical (my) Variables |  | 4.11. The return Operator |