3 $strict::VERSION = "1.02";
15 push @wrong, $s unless exists $bitmask{$s};
16 $bits |= $bitmask{$s} || 0;
20 Carp::croak("Unknown 'strict' tag(s) '@wrong'");
27 $^H |= bits(@_ ? @_ : qw(refs subs vars));
32 $^H &= ~ bits(@_ ? @_ : qw(refs subs vars));
40 strict - Perl pragma to restrict unsafe constructs
55 If no import list is supplied, all possible restrictions are assumed.
56 (This is the safest mode to operate in, but is sometimes too strict for
57 casual programming.) Currently, there are three possible things to be
58 strict about: "subs", "vars", and "refs".
64 This generates a runtime error if you
65 use symbolic references (see L<perlref>).
71 print $$ref; # runtime error; normally ok
73 print $file "Hi!"; # error; note: no comma after $file
75 There is one exception to this rule:
80 is allowed so that C<goto &$AUTOLOAD> would not break under stricture.
85 This generates a compile-time error if you access a variable that wasn't
86 declared via "our" or C<use vars>,
87 localized via C<my()>, or wasn't fully qualified. Because this is to avoid
88 variable suicide problems and subtle dynamic scoping issues, a merely
89 local() variable isn't good enough. See L<perlfunc/my> and
93 $X::foo = 1; # ok, fully qualified
94 my $foo = 10; # ok, my() var
95 local $foo = 9; # blows up
98 our $bar; # Declares $bar in current package
99 $bar = 'HgS'; # ok, global declared via pragma
101 The local() generated a compile-time error because you just touched a global
102 name without fully qualifying it.
104 Because of their special use by sort(), the variables $a and $b are
105 exempted from this check.
109 This disables the poetry optimization, generating a compile-time error if
110 you try to use a bareword identifier that's not a subroutine, unless it
111 appears in curly braces or on the left hand side of the "=E<gt>" symbol.
115 $SIG{PIPE} = Plumber; # blows up
116 $SIG{PIPE} = "Plumber"; # just fine: bareword in curlies always ok
117 $SIG{PIPE} = \&Plumber; # preferred form
123 See L<perlmodlib/Pragmatic Modules>.