5 strict - Perl pragma to restrict unsafe constructs
21 If no import list is supplied, all possible restrictions are assumed.
22 (This is the safest mode to operate in, but is sometimes too strict for
23 casual programming.) Currently, there are four possible things to be
24 strict about: "subs", "vars", "refs", and "untie".
30 This generates a runtime error if you
31 use symbolic references (see L<perlref>).
37 print $$ref; # runtime error; normally ok
41 This generates a compile-time error if you access a variable that wasn't
42 localized via C<my()> or wasn't fully qualified. Because this is to avoid
43 variable suicide problems and subtle dynamic scoping issues, a merely
44 local() variable isn't good enough. See L<perlfunc/my> and
48 $X::foo = 1; # ok, fully qualified
49 my $foo = 10; # ok, my() var
50 local $foo = 9; # blows up
52 The local() generated a compile-time error because you just touched a global
53 name without fully qualifying it.
57 This disables the poetry optimization, generating a compile-time error if
58 you try to use a bareword identifier that's not a subroutine, unless it
59 appears in curly braces or on the left hand side of the "=>" symbol.
63 $SIG{PIPE} = Plumber; # blows up
64 $SIG{PIPE} = "Plumber"; # just fine: bareword in curlies always ok
65 $SIG{PIPE} = \&Plumber; # preferred form
71 This generates a runtime error if any references to the object returned
72 by C<tie> (or C<tied>) still exist when C<untie> is called. Note that
73 to get this strict behaviour, the C<use strict 'untie'> statement must
74 be in the same scope as the C<untie>. See L<perlfunc/tie>,
75 L<perlfunc/untie>, L<perlfunc/tied> and L<perltie>.
78 $a = tie %a, 'SOME_PKG';
79 $b = tie %b, 'SOME_PKG';
83 untie %a ; # blows up, $a is a valid object reference.
84 untie %b; # ok, $b is not a reference to the object.
85 untie %c ; # blows up, $c is a valid object reference.
89 See L<perlmod/Pragmatic Modules>.
96 foreach $sememe (@_) {
97 $bits |= 0x00000002 if $sememe eq 'refs';
98 $bits |= 0x00000200 if $sememe eq 'subs';
99 $bits |= 0x00000400 if $sememe eq 'vars';
100 $bits |= 0x00000800 if $sememe eq 'untie';
107 $^H |= bits(@_ ? @_ : qw(refs subs vars untie));
112 $^H &= ~ bits(@_ ? @_ : qw(refs subs vars untie));