3 $strict::VERSION
= "1.03";
15 push @wrong, $s unless exists $bitmask{$s};
16 $bits |= $bitmask{$s} || 0;
20 Carp
::croak
("Unknown 'strict' tag(s) '@wrong'");
25 my $default_bits = bits
(qw(refs subs vars));
29 $^H
|= @_ ? bits
(@_) : $default_bits;
34 $^H
&= ~ (@_ ? bits
(@_) : $default_bits);
42 strict - Perl pragma to restrict unsafe constructs
57 If no import list is supplied, all possible restrictions are assumed.
58 (This is the safest mode to operate in, but is sometimes too strict for
59 casual programming.) Currently, there are three possible things to be
60 strict about: "subs", "vars", and "refs".
66 This generates a runtime error if you
67 use symbolic references (see L<perlref>).
73 print $$ref; # runtime error; normally ok
75 print $file "Hi!"; # error; note: no comma after $file
77 There is one exception to this rule:
82 is allowed so that C<goto &$AUTOLOAD> would not break under stricture.
87 This generates a compile-time error if you access a variable that wasn't
88 declared via C<our> or C<use vars>,
89 localized via C<my()>, or wasn't fully qualified. Because this is to avoid
90 variable suicide problems and subtle dynamic scoping issues, a merely
91 local() variable isn't good enough. See L<perlfunc/my> and
95 $X::foo = 1; # ok, fully qualified
96 my $foo = 10; # ok, my() var
97 local $foo = 9; # blows up
100 our $bar; # Declares $bar in current package
101 $bar = 'HgS'; # ok, global declared via pragma
103 The local() generated a compile-time error because you just touched a global
104 name without fully qualifying it.
106 Because of their special use by sort(), the variables $a and $b are
107 exempted from this check.
111 This disables the poetry optimization, generating a compile-time error if
112 you try to use a bareword identifier that's not a subroutine, unless it
113 is a simple identifier (no colons) and that it appears in curly braces or
114 on the left hand side of the C<< => >> symbol.
117 $SIG{PIPE} = Plumber; # blows up
118 $SIG{PIPE} = "Plumber"; # just fine: quoted string is always ok
119 $SIG{PIPE} = \&Plumber; # preferred form
123 See L<perlmodlib/Pragmatic Modules>.
127 C<strict 'subs'>, with Perl 5.6.1, erroneously permitted to use an unquoted
128 compound identifier (e.g. C<Foo::Bar>) as a hash key (before C<< => >> or
129 inside curlies), but without forcing it always to a literal string.
131 Starting with Perl 5.8.1 strict is strict about its restrictions:
132 if unknown restrictions are used, the strict pragma will abort with
134 Unknown 'strict' tag(s) '...'