5 strict - Perl pragma to restrict unsafe constructs
20 If no import list is supplied, all possible restrictions are assumed.
21 (This is the safest mode to operate in, but is sometimes too strict for
22 casual programming.) Currently, there are three possible things to be
23 strict about: "subs", "vars", and "refs".
29 This generates a runtime error if you
30 use symbolic references (see L<perlref>).
36 print $$ref; # runtime error; normally ok
38 print $file "Hi!"; # error; note: no comma after $file
40 There is one exception to this rule:
45 is allowed so that C<goto &$AUTOLOAD> would not break under stricture.
50 This generates a compile-time error if you access a variable that wasn't
51 declared via "our" or C<use vars>,
52 localized via C<my()>, or wasn't fully qualified. Because this is to avoid
53 variable suicide problems and subtle dynamic scoping issues, a merely
54 local() variable isn't good enough. See L<perlfunc/my> and
58 $X::foo = 1; # ok, fully qualified
59 my $foo = 10; # ok, my() var
60 local $foo = 9; # blows up
63 our $bar; # Declares $bar in current package
64 $bar = 'HgS'; # ok, global declared via pragma
66 The local() generated a compile-time error because you just touched a global
67 name without fully qualifying it.
69 Because of their special use by sort(), the variables $a and $b are
70 exempted from this check.
74 This disables the poetry optimization, generating a compile-time error if
75 you try to use a bareword identifier that's not a subroutine, unless it
76 appears in curly braces or on the left hand side of the "=E<gt>" symbol.
80 $SIG{PIPE} = Plumber; # blows up
81 $SIG{PIPE} = "Plumber"; # just fine: bareword in curlies always ok
82 $SIG{PIPE} = \&Plumber; # preferred form
88 See L<perlmodlib/Pragmatic Modules>.
93 $strict::VERSION
= "1.01";
103 foreach my $s (@_){ $bits |= $bitmask{$s} || 0; };
109 $^H
|= bits
(@_ ?
@_ : qw(refs subs vars));
114 $^H
&= ~ bits
(@_ ?
@_ : qw(refs subs vars));