MAN page from Old RedHat 5.X perl-5.004-4.i386.rpm
strict
Section: Perl Programmers Reference Guide (3)
Updated: perl 5.004, patch 04
Index NAME
strict - Perl pragma to restrict unsafe constructs
SYNOPSIS
use strict;
use strict "vars"; use strict "refs"; use strict "subs";
use strict; no strict "vars";
DESCRIPTION
If no import list is supplied, all possible restrictions are assumed.(This is the safest mode to operate in, but is sometimes too strict forcasual programming.) Currently, there are three possible things to bestrict about: ``subs'', ``vars'', and ``refs''.
- strict refs
- This generates a runtime error if you use symbolic references (see the perlref manpage).
use strict 'refs'; $ref = \$foo; print $$ref; # ok $ref = "foo"; print $$ref; # runtime error; normally ok
- strict vars
- This generates a compile-time error if you access a variable that wasn'tlocalized via my() or wasn't fully qualified. Because this is to avoidvariable suicide problems and subtle dynamic scoping issues, a merelylocal() variable isn't good enough. See the my entry in the perlfunc manpage andthe local entry in the perlfunc manpage.
use strict 'vars'; $X::foo = 1; # ok, fully qualified my $foo = 10; # ok, my() var local $foo = 9; # blows up
The local() generated a compile-time error because you just touched a globalname without fully qualifying it.
- strict subs
- This disables the poetry optimization, generating a compile-time error ifyou try to use a bareword identifier that's not a subroutine, unless itappears in curly braces or on the left hand side of the ``=>'' symbol.
use strict 'subs'; $SIG{PIPE} = Plumber; # blows up $SIG{PIPE} = "Plumber"; # just fine: bareword in curlies always ok $SIG{PIPE} = \&Plumber; # preferred form
See the section on Pragmatic Modules in the perlmod manpage.
Index
- NAME
- SYNOPSIS
- DESCRIPTION
This document was created byman2html,using the manual pages.