=encoding euc-jp =head1 NAME =begin original strict - Perl pragma to restrict unsafe constructs =end original strict - 安全ではない構文を制限する Perl プラグマ =head1 SYNOPSIS use strict; use strict "vars"; use strict "refs"; use strict "subs"; use strict; no strict "vars"; =head1 DESCRIPTION =begin original If no import list is supplied, all possible restrictions are assumed. (This is the safest mode to operate in, but is sometimes too strict for casual programming.) Currently, there are three possible things to be strict about: "subs", "vars", and "refs". =end original インポートリストを与えない場合は、利用可能な全ての制約を受けます。 (これは最も安全な動作モードですが、カジュアルプログラミングの ためには厳しすぎる場合もあります。) 今のところ、"subs"、"vars"、"refs" の 3 つの制約が用意されています。 =over 6 =item C =begin original This generates a runtime error if you use symbolic references (see L). =end original シンボリックリファレンスが使われたときに実行時エラーになります。 (L を見てください。) =begin original use strict 'refs'; $ref = \$foo; print $$ref; # ok $ref = "foo"; print $$ref; # runtime error; normally ok $file = "STDOUT"; print $file "Hi!"; # error; note: no comma after $file =end original use strict 'refs'; $ref = \$foo; print $$ref; # ok $ref = "foo"; print $$ref; # ランタイムエラー; 普段は ok $file = "STDOUT"; print $file "Hi!"; # エラー; 注意: $file の後にコンマがない =begin original There is one exception to this rule: =end original このルールには 1 つの例外があります: $bar = \&{'foo'}; &$bar; =begin original is allowed so that C would not break under stricture. =end original 上記のものは許容されます; だから C はこの制約下でも動きます。 =item C =begin original This generates a compile-time error if you access a variable that wasn't declared via C or C, localized via C, or wasn't fully qualified. Because this is to avoid variable suicide problems and subtle dynamic scoping issues, a merely local() variable isn't good enough. See L and L. =end original C や C、C で宣言された変数や完全に修飾された 変数以外にアクセスしたときにコンパイル時エラーを出します。 変数が自殺してしまう問題や微妙な動的スコープの問題があるため、 local() 変数だけでは十分ではありません。 L や L を見てください。 =begin original use strict 'vars'; $X::foo = 1; # ok, fully qualified my $foo = 10; # ok, my() var local $foo = 9; # blows up =end original use strict 'vars'; $X::foo = 1; # ok, 完全に修飾されています my $foo = 10; # ok, my() 変数 local $foo = 9; # ダメ =begin original package Cinna; our $bar; # Declares $bar in current package $bar = 'HgS'; # ok, global declared via pragma =end original package Cinna; our $bar; # パッケージ内で宣言された $bar $bar = 'HgS'; # ok, プラグマでグローバルに宣言された =begin original The local() generated a compile-time error because you just touched a global name without fully qualifying it. =end original local() は、完全な修飾無しにグローバルな名前を触ってしまうため コンパイル時エラーを出します。 =begin original Because of their special use by sort(), the variables $a and $b are exempted from this check. =end original sort() によって特別扱いされるという理由で $a と $b はこのチェックの 適用外になっています。 =item C =begin original This disables the poetry optimization, generating a compile-time error if you try to use a bareword identifier that's not a subroutine, unless it is a simple identifier (no colons) and that it appears in curly braces or on the left hand side of the C<< => >> symbol. =end original 詩的な最適化を禁止し、サブルーチン以外の裸の識別子を使おうとしたとき、 それが(コロンのない)単純な識別子や中括弧の中 C<< => >> シンボルの 左側でない場合にコンパイル時エラーを出します。 =begin original use strict 'subs'; $SIG{PIPE} = Plumber; # blows up $SIG{PIPE} = "Plumber"; # just fine: quoted string is always ok $SIG{PIPE} = \&Plumber; # preferred form =end original use strict 'subs'; $SIG{PIPE} = Plumber; # ダメ $SIG{PIPE} = "Plumber"; # 問題なし: クォートされた文字は常に ok $SIG{PIPE} = \&Plumber; # 好ましい方法 =back =begin original See L. =end original L を見てください。 =head1 HISTORY =begin original C, with Perl 5.6.1, erroneously permitted to use an unquoted compound identifier (e.g. C) as a hash key (before C<< => >> or inside curlies), but without forcing it always to a literal string. =end original Perl 5.6.1 での C は、(C<< => >> の前や中括弧の中での) ハッシュのキーのとして、クォートすることなしに(C のような) 複合の識別子を使えるようにしてしまっています; このことは間違いでした; それは、いつでもリテラル文字列です。 =begin original Starting with Perl 5.8.1 strict is strict about its restrictions: if unknown restrictions are used, the strict pragma will abort with =end original Perl 5.8.1 からの strict は、それらの制約事項について厳格です: もし、知られていない制約事項が使われるならば、strict プラグマは、 以下のような出力と共に中断します。 Unknown 'strict' tag(s) '...' =begin original As of version 1.04 (Perl 5.10), strict verifies that it is used as "strict" to avoid the dreaded Strict trap on case insensitive file systems. =end original バージョン 1.04 (Perl 5.10) から、大文字小文字の区別のない ファイルシステムでの恐ろしい "Strict" の罠を避けるために、strict は "strict" として使われているかを検証します。 =begin meta Update: Kentaro Shirakata (1.04) =end meta =cut