3 $strict::VERSION = "1.02";
15 push @wrong, $s unless exists $bitmask{$s};
16 $bits |= $bitmask{$s} || 0;
20 __PACKAGE__.'::import' => 'use',
21 __PACKAGE__.'::unimport' => 'no'
22 }->{ (caller(1))[3] };
24 Carp::croak("Don't know how to '$useno ".__PACKAGE__." qw(@wrong)'");
31 $^H |= bits(@_ ? @_ : qw(refs subs vars));
36 $^H &= ~ bits(@_ ? @_ : qw(refs subs vars));
44 strict - Perl pragma to restrict unsafe constructs
59 If no import list is supplied, all possible restrictions are assumed.
60 (This is the safest mode to operate in, but is sometimes too strict for
61 casual programming.) Currently, there are three possible things to be
62 strict about: "subs", "vars", and "refs".
68 This generates a runtime error if you
69 use symbolic references (see L<perlref>).
75 print $$ref; # runtime error; normally ok
77 print $file "Hi!"; # error; note: no comma after $file
79 There is one exception to this rule:
84 is allowed so that C<goto &$AUTOLOAD> would not break under stricture.
89 This generates a compile-time error if you access a variable that wasn't
90 declared via "our" or C<use vars>,
91 localized via C<my()>, or wasn't fully qualified. Because this is to avoid
92 variable suicide problems and subtle dynamic scoping issues, a merely
93 local() variable isn't good enough. See L<perlfunc/my> and
97 $X::foo = 1; # ok, fully qualified
98 my $foo = 10; # ok, my() var
99 local $foo = 9; # blows up
102 our $bar; # Declares $bar in current package
103 $bar = 'HgS'; # ok, global declared via pragma
105 The local() generated a compile-time error because you just touched a global
106 name without fully qualifying it.
108 Because of their special use by sort(), the variables $a and $b are
109 exempted from this check.
113 This disables the poetry optimization, generating a compile-time error if
114 you try to use a bareword identifier that's not a subroutine, unless it
115 appears in curly braces or on the left hand side of the "=E<gt>" symbol.
119 $SIG{PIPE} = Plumber; # blows up
120 $SIG{PIPE} = "Plumber"; # just fine: bareword in curlies always ok
121 $SIG{PIPE} = \&Plumber; # preferred form
127 See L<perlmodlib/Pragmatic Modules>.