perl-5.38.0
state VARLIST
state TYPE VARLIST
state VARLIST : ATTRS
state TYPE VARLIST : ATTRS

state declares a lexically scoped variable, just like my. However, those variables will never be reinitialized, contrary to lexical variables that are reinitialized each time their enclosing block is entered. See "Persistent Private Variables" in perlsub for details.

state はちょうど my と同様に、 レキシカルなスコープの変数を宣言します。 しかし、レキシカル変数がブロックに入る毎に再初期化されるのと異なり、 この変数は決して再初期化されません。 詳しくは "Persistent Private Variables" in perlsub を参照してください。

If more than one variable is listed, the list must be placed in parentheses. With a parenthesised list, undef can be used as a dummy placeholder. However, since initialization of state variables in such lists is currently not possible this would serve no purpose.

複数の変数を指定する場合は、リストはかっこで囲まなければなりません。 かっこで囲まれたリストでは、undef はダミーの プレースホルダとして使えます。 しかし、そのようなリストでの state 変数の初期化は現在のところできないので、 これは無意味です。

Redeclaring a variable in the same scope or statement will "shadow" the previous declaration, creating a new instance and preventing access to the previous one. This is usually undesired and, if warnings are enabled, will result in a warning in the shadow category.

同じスコープや文で変数を再宣言すると、以前の宣言を「隠し」、 新しい実体を作って、以前の実体にアクセスできなくなります。 これは普通は望まれているものではなく、警告が有効なら、 shadow カテゴリの警告が出ます。

state is available only if the "state" feature is enabled or if it is prefixed with CORE::. The "state" feature is enabled automatically with a use v5.10 (or higher) declaration in the current scope.

state"state" 機能 が有効か CORE:: を 前置した場合にのみ利用可能です。 "state" 機能 は現在のスコープで use v5.10 (またはそれ以上) を宣言した場合自動的に有効になります。