> What does exactly does use strict do? 

Here's a sample:

use strict;

use vars qw( $a $b $c     # this is how you declare variables
             $myvar   );  # for use with "use strict"

$a = 1;                   #ok
$b = 2;                   #ok
$c = $a + b;              #oops, forgot $ in front of "b"!
# Error: Bareword "b" not allowed while "strict subs" in use

$d = 2 * $c;              #oops, $d not declared in "use vars"
# Error: Global symbol "$d" requires explicit package name

$myVar = $c;              #oops, capitalization error
# Error: Global symbol "$myVar" requires explicity package name

So "use strict" functions as something of a safety net -- it makes you think
about what variables you're using, and helps catch misspellings and such.

Reply via email to