perlvar > 5.14.1 との差分

perlvar 5.14.1 と 5.40.0 の差分

11
2=encoding euc-jp
2=encoding utf8
33
44=head1 NAME
55
66=begin original
77
88perlvar - Perl predefined variables
99
1010=end original
1111
1212perlvar - Perl で定義済みの変数
1313
1414=head1 DESCRIPTION
1515
1616=head2 The Syntax of Variable Names
1717
1818(変数名の文法)
1919
2020=begin original
2121
22Variable names in Perl can have several formats. Usually, they
22Variable names in Perl can have several formats. Usually, they
2323must begin with a letter or underscore, in which case they can be
2424arbitrarily long (up to an internal limit of 251 characters) and
2525may contain letters, digits, underscores, or the special sequence
26C<::> or C<'>. In this case, the part before the last C<::> or
26C<::> or C<'>. In this case, the part before the last C<::> or
2727C<'> is taken to be a I<package qualifier>; see L<perlmod>.
28A Unicode letter that is not ASCII is not considered to be a letter
29unless S<C<"use utf8">> is in effect, and somewhat more complicated
30rules apply; see L<perldata/Identifier parsing> for details.
2831
2932=end original
3033
3134Perl の変数名は様々な形があります。
3235通常、変数名は英文字か下線で始まらなければならず、
3336任意の長さ(内部制限の 251 文字まで)を取ることができ、
3437英文字、数字、下線、特別な文字列である C<::> と C<'> を含むことができます。
35この場合、最後の C<::> または C<'> の前は
38この場合、最後の C<::> または C<'> の前は I<パッケージ限定子> として
36I<パッケージ限定子> として扱われます。
39扱われます; L<perlmod> を参照して下さい
37L<perlmod> を参照して下さ
40ASCII ではない Unicode 文字は、S<C<"use utf8">> が有効でな限り
41文字として扱われません; そしていくらかより複雑な規則が適用されます;
42詳しくは L<perldata/Identifier parsing> を参照してください。
3843
3944=begin original
4045
41Perl variable names may also be a sequence of digits or a single
46Perl variable names may also be a sequence of digits, a single
42punctuation or control character. These names are all reserved for
47punctuation character, or the two-character sequence: C<^> (caret or
48CIRCUMFLEX ACCENT) followed by any one of the characters C<[][A-Z^_?\]>.
49These names are all reserved for
4350special uses by Perl; for example, the all-digits names are used
4451to hold data captured by backreferences after a regular expression
45match. Perl has a special syntax for the single-control-character
52match.
46names: It understands C<^X> (caret C<X>) to mean the control-C<X>
47character. For example, the notation C<$^W> (dollar-sign caret
48C<W>) is the scalar variable whose name is the single character
49control-C<W>. This is better than typing a literal control-C<W>
50into your program.
5153
5254=end original
5355
54Perl の変数は、数字の列または一文字の句読点かコントロール文字
56Perl の変数は、数字の列または一文字の句読点文字、2 文字並び(
55場合もあります。
57C<^> (キャレット、CIRCUMFLEX ACCENT) に引き続いて C<[][A-Z^_?\]> の文字の一つ)
56これら名前は全て Perl によって特別な用途のために予約されています。
58場合もあります。
59これらの名前は全て Perl によって特別な用途のために予約されています;
5760例えば、全て数字の名前は正規表現マッチの後の後方参照のデータを
5861保持するために用いられます。
59Perl には一文字のコントロール文字の名前のための特別な文法があります。
60C<^X>(キャレット C<X>)は control-C<X> キャラクタを意味します。
61例えば、C<$^W>(ドル記号 キャレット C<W>)は control-C<W> 一文字の
62名前をもつスカラ変数です。
63これはプログラム中にリテラルな control-C<W> をタイプするより
64良いです。
6562
6663=begin original
6764
68Since Perl 5.6, Perl variable names may be alphanumeric
65Since Perl v5.6.0, Perl variable names may also be alphanumeric strings
69strings that begin with control characters (or better yet, a caret).
66preceded by a caret. These must all be written using the demarcated
70These variables must be written in the form C<${^Foo}>; the braces
67variable form using curly braces such as C<${^Foo}>;
71are not optional. C<${^Foo}> denotes the scalar variable whose
68the braces are B<not> optional. C<${^Foo}> denotes the scalar variable
72name is a control-C<F> followed by two C<o>'s. These variables are
69whose name is considered to be a control-C<F> followed by two C<o>'s.
70(See L<perldata/"Demarcated variable names using braces"> for more
71information on this form of spelling a variable name or specifying
72access to an element of an array or a hash).
73These variables are
7374reserved for future special uses by Perl, except for the ones that
74begin with C<^_> (control-underscore or caret-underscore). No
75begin with C<^_> (caret-underscore). No
75control-character name that begins with C<^_> will acquire a special
76name that begins with C<^_> will acquire a special
7677meaning in any future version of Perl; such names may therefore be
77used safely in programs. C<$^_> itself, however, I<is> reserved.
78used safely in programs. C<$^_> itself, however, I<is> reserved.
7879
7980=end original
8081
81Perl 5.6 から、制御文字(もっと言えばキャレット)で始まる、英数字からなる
82Perl v5.6.0 から、キャレットが前置された、英数字からなる文字列の変数名も
82文字列の変数名も使えます。
83使えます。
83これらの変数は C<${^Foo}> の形で書かれければなりません。
84これらは C<${^Foo}> のよう中かっこを使った
84括弧は必須す。
85区切り付き変数形式書かれなければなりません;
86括弧はオプション B<ではありません>。
8587C<${^Foo}> はコントロール-C<F> の後に二つ C<o> が続く名前を持つ
86スカラ変数す。
88スカラ変数と考えられます。
89(変数名をこの形式で書くことや配列やハッシュの要素へのアクセスを指定する
90さらなる情報については
91L<perldata/"Demarcated variable names using braces"> を参照してください。)
8792これらの変数は Perl によって特別な用途のために予約されていますが、
88C<^_> (コントロール-下線またはキャレット-下線)で始まるものは例外です。
93C<^_> (キャレット-下線)で始まるものは例外です。
89C<^_> で始まるコントロール文字名は Perl の将来のバージョンで
94C<^_> で始まる名は Perl の将来のバージョンで特別な意味を
90特別な意味を持つことはありません。
95持つことはありません; 従ってこれらの名前はプログラム中で安全に使用できます
91従ってこれらの名前はプログラム中で安全に使用できます。
9296但し、C<$^_> そのものは I<予約されます>。
9397
9498=begin original
9599
96Perl identifiers that begin with digits, control characters, or
100Note that you also B<must> use the demarcated form to access subscripts
101of variables of this type when interpolating, for instance to access the
102first element of the C<@{^CAPTURE}> variable inside of a double quoted
103string you would write C<"${^CAPTURE[0]}"> and NOT C<"${^CAPTURE}[0]">
104which would mean to reference a scalar variable named C<${^CAPTURE}> and
105not index 0 of the magic C<@{^CAPTURE}> array which is populated by the
106regex engine.
107
108=end original
109
110この種類の変数の添え字にアクセスするためにも境界を定める形式を
111B<使わなければならない> ことに注意してください;
112例えば、ダブルクォート文字列の中で
113C<@{^CAPTURE}> 変数の最初の要素にアクセスするには、
114C<"${^CAPTURE}[0]"> ではなく C<"${^CAPTURE[0]}"> と書きます;
115前者は C<${^CAPTURE}> という名前のスカラ変数へのリファレンスで、
116正規表現エンジンによって設定された C<@{^CAPTURE}> マジック配列の
117インデックス 0 ではありません。
118
119=begin original
120
121Perl identifiers that begin with digits or
97122punctuation characters are exempt from the effects of the C<package>
98123declaration and are always forced to be in package C<main>; they are
99also exempt from C<strict 'vars'> errors. A few other names are also
124also exempt from C<strict 'vars'> errors. A few other names are also
100125exempt in these ways:
101126
102127=end original
103128
104数字、コントロール文字、句読点で始まる Perl の識別子は
129数字、句読点で始まる Perl の識別子は C<package> 宣言の
105C<package> 宣言の効果から逃れて、常に C<main> パッケージにあるものとして
130効果から逃れて、常に C<main> パッケージにあるものとして扱われます。
106扱われます。さらに以下のものも逃れます:
131さらに以下のものも逃れます:
107132
108 ENV STDIN
133 ENV STDIN
109 INC STDOUT
134 INC STDOUT
110 ARGV STDERR
135 ARGV STDERR
111 ARGVOUT
136 ARGVOUT
112 SIG
137 SIG
113138
114139=begin original
115140
116141In particular, the special C<${^_XYZ}> variables are always taken
117142to be in package C<main>, regardless of any C<package> declarations
118143presently in scope.
119144
120145=end original
121146
122147特に、新しい特別な C<${^_XYZ}> 変数はスコープ内の C<package> 宣言に関わらず
123148常に C<main> パッケージとして扱われます。
124149
125150=head1 SPECIAL VARIABLES
126151
127152(特殊変数)
128153
129154=begin original
130155
131The following names have special meaning to Perl. Most punctuation
156The following names have special meaning to Perl. Most punctuation
132157names have reasonable mnemonics, or analogs in the shells.
133158Nevertheless, if you wish to use long variable names, you need only say:
134159
135160=end original
136161
137162以下の名前は Perl では特別な意味を持ちます。
138163記号的な名前の多くは記憶法があるか、シェルでの類推が可能です。
139164それでも長い名前を使用したい場合には
140165
141 use English;
166 use English;
142167
143168=begin original
144169
145at the top of your program. This aliases all the short names to the long
170at the top of your program. This aliases all the short names to the long
146names in the current package. Some even have medium names, generally
171names in the current package. Some even have medium names, generally
147borrowed from B<awk>. To avoid a performance hit, if you don't need the
172borrowed from B<awk>. For more info, please see L<English>.
148C<$PREMATCH>, C<$MATCH>, or C<$POSTMATCH> it's best to use the C<English>
149module without them:
150173
151174=end original
152175
153176とプログラムの最初に書いてください。
154177これは、すべての短い名前の別名として、
155178カレントパッケージで長い名前を付けるものです。
156179B<awk> から持ってきた中間的な名前を持っているものもあります。
157パフォーマンスの影響を避けために、もし C<$PREMATCH>, C<$MATCH>,
180さらな情報ついてはどうか L<English> を参照してください。
158C<$POSTMATCH> が必要ないなら、これらなしで C<English> モジュールを使うのが
159最善です:
160181
161 use English '-no_match_vars';
162
163182=begin original
164183
165Before you continue, note the sort order for variables. In general, we
184Before you continue, note the sort order for variables. In general, we
166185first list the variables in case-insensitive, almost-lexigraphical
167186order (ignoring the C<{> or C<^> preceding words, as in C<${^UNICODE}>
168187or C<$^T>), although C<$_> and C<@_> move up to the top of the pile.
169188For variables with the same identifier, we list it in order of scalar,
170189array, hash, and bareword.
171190
172191=end original
173192
174193先に進む前に、変数のソート順に注意してください。
175194一般的に、変数を大文字小文字を無視して、ほとんど辞書順に並んでいます
176(C<${^UNICODE}> や C<$^T> 先頭についている C<{> や C<^> は無視します)が、
195(C<${^UNICODE}> や C<$^T> のように、先頭についている C<{> や C<^> は
177C<$_> と C<@_> は先頭に来ます。
196無視します)が、C<$_> と C<@_> は先頭に来ます。
178197同じ識別子を持つ変数については、スカラ、配列、ハッシュ、裸の単語の順に
179198並べています。
180199
181200=head2 General Variables
182201
183202(一般変数)
184203
185204=over 8
186205
187206=item $ARG
188207
189208=item $_
190209X<$_> X<$ARG>
191210
192211=begin original
193212
194The default input and pattern-searching space. The following pairs are
213The default input and pattern-searching space. The following pairs are
195214equivalent:
196215
197216=end original
198217
199218デフォルトの入力とパターン検索のスペース。
200219以下の 2つは同値です:
201220
202 while (<>) {...} # equivalent only in while!
221=begin original
203 while (defined($_ = <>)) {...}
204222
205 /^Subject:/
223 while (<>) {...} # equivalent only in while!
206 $_ =~ /^Subject:/
224 while (defined($_ = <>)) {...}
207225
208 tr/a-z/A-Z/
226=end original
209 $_ =~ tr/a-z/A-Z/
210227
211 chomp
228 while (<>) {...} # while の中でのみ等価!
212 chomp($_)
229 while (defined($_ = <>)) {...}
213230
231 /^Subject:/
232 $_ =~ /^Subject:/
233
234 tr/a-z/A-Z/
235 $_ =~ tr/a-z/A-Z/
236
237 chomp
238 chomp($_)
239
214240=begin original
215241
216242Here are the places where Perl will assume C<$_> even if you don't use it:
217243
218244=end original
219245
220246あなたが使いたくなくても Perl が C<$_> を仮定する場合がいくつかあります:
221247
222248=over 3
223249
224250=item *
225251
226252=begin original
227253
228254The following functions use C<$_> as a default argument:
229255
230256=end original
231257
232258以下の関数は C<$_> をデフォルト引数として使います:
233259
234260=begin original
235261
236abs, alarm, chomp, chop, chr, chroot, cos, defined, eval, exp, glob,
262abs, alarm, chomp, chop, chr, chroot,
237hex, int, lc, lcfirst, length, log, lstat, mkdir, oct, ord, pos, print,
263cos, defined, eval, evalbytes, exp, fc, glob, hex, int, lc,
264lcfirst, length, log, lstat, mkdir, oct, ord, pos, print, printf,
238265quotemeta, readlink, readpipe, ref, require, reverse (in scalar context only),
239rmdir, sin, split (on its second argument), sqrt, stat, study, uc, ucfirst,
266rmdir, say, sin, split (for its second
267argument), sqrt, stat, study, uc, ucfirst,
240268unlink, unpack.
241269
242270=end original
243271
244abs, alarm, chomp, chop, chr, chroot, cos, defined, eval, exp, glob,
272abs, alarm, chomp, chop, chr, chroot,
245hex, int, lc, lcfirst, length, log, lstat, mkdir, oct, ord, pos, print,
273cos, defined, eval, evalbytes, exp, fc, glob, hex, int, lc,
274lcfirst, length, log, lstat, mkdir, oct, ord, pos, print, printf,
246275quotemeta, readlink, readpipe, ref, require, reverse (スカラコンテキストのみ),
247rmdir, sin, split (の 2 番目の引数), sqrt, stat, study, uc, ucfirst,
276rmdir, say, sin, split (の 2 番目の引数),
248unlink, unpack.
277sqrt, stat, study, uc, ucfirst,
278unlink, unpack
249279
250280=item *
251281
252282=begin original
253283
254284All file tests (C<-f>, C<-d>) except for C<-t>, which defaults to STDIN.
255285See L<perlfunc/-X>
256286
257287=end original
258288
259デフォルトが STDIN である C<-t> を除く全てのファイルテスト(C<-f>, C<-d>)
289デフォルトが STDIN である C<-t> を除く全てのファイルテスト(C<-f>, C<-d>)。
260290L<perlfunc/-X> を参照してください。
261291
262292=item *
263293
264294=begin original
265295
266296The pattern matching operations C<m//>, C<s///> and C<tr///> (aka C<y///>)
267297when used without an C<=~> operator.
268298
269299=end original
270300
271301C<=~> 演算子なしで用いられたパターンマッチ演算 C<m//>, C<s///>, C<tr///>
272302(またの名を C<y///>)。
273303
274304=item *
275305
276306=begin original
277307
278308The default iterator variable in a C<foreach> loop if no other
279309variable is supplied.
280310
281311=end original
282312
283C<foreach> ループでの他の変数が補われなかった場合のデフォルトの
313C<foreach> ループでの他の変数が補われなかった場合のデフォルトの繰り返し変数。
284繰り返し変数。
285314
286315=item *
287316
288317=begin original
289318
290319The implicit iterator variable in the C<grep()> and C<map()> functions.
291320
292321=end original
293322
294323C<grep()> 関数と C<map()> 関数の暗黙の繰り返し変数。
295324
296325=item *
297326
298327=begin original
299328
300329The implicit variable of C<given()>.
301330
302331=end original
303332
304333C<given()> の暗黙の変数。
305334
306335=item *
307336
308337=begin original
309338
310The default place to put an input record when a C<< <FH> >>
339The default place to put the next value or input record
340when a C<< <FH> >>, C<readline>, C<readdir> or C<each>
311341operation's result is tested by itself as the sole criterion of a C<while>
312test. Outside a C<while> test, this will not happen.
342test. Outside a C<while> test, this will not happen.
313343
314344=end original
315345
316C<< <FH> >> が単独で C<while> テストでテストされた場合の
346C<< <FH> >>, C<readline>, C<readdir>, C<each> が単独で C<while> テストで
317結果を入れるデフォルトの場所。
347テストされた場合の、次の値や入力レコードを入れるデフォルトの場所。
318348C<while> テスト以外ではこれは起こりません。
319349
320350=back
321351
322352=begin original
323353
324As C<$_> is a global variable, this may lead in some cases to unwanted
354C<$_> is a global variable.
325side-effects. As of perl 5.9.1, you can now use a lexical version of
326C<$_> by declaring it in a file or in a block with C<my>. Moreover,
327declaring C<our $_> restores the global C<$_> in the current scope.
328355
329356=end original
330357
331C<$_> はグローバル変数なの、望まないような副作用を引き起こす場合があります。
358C<$_> はグローバル変数です。
332perl 5.9.1 から、ファイルやブロックで C<my> で宣言することで、
333レキシカル版の C<$_> が使えます。
334さらに、C<our $_> という宣言は現在のスコープでグローバルな C<$_> を
335再構築します。
336359
337360=begin original
338361
362However, between perl v5.10.0 and v5.24.0, it could be used lexically by
363writing C<my $_>. Making C<$_> refer to the global C<$_> in the same scope
364was then possible with C<our $_>. This experimental feature was removed and is
365now a fatal error, but you may encounter it in older code.
366
367=end original
368
369しかし、perl v5.10.0 から v5.24.0 の間、
370C<my $_> と書くことでこれをレキシカルに使うことが出来ました。
371同じスコープで C<$_> がグローバルな C<$_> を参照するのは
372C<our $_> で可能になっていました。
373この実験的機能は削除されて今では致命的エラーですが、
374古いコードで見かけるかも知れません。
375
376=begin original
377
339378Mnemonic: underline is understood in certain operations.
340379
341380=end original
342381
343382記憶法: 下線はある操作を覚えるためのもの。
344383
345384=item @ARG
346385
347386=item @_
348387X<@_> X<@ARG>
349388
350389=begin original
351390
352391Within a subroutine the array C<@_> contains the parameters passed to
353that subroutine. Inside a subroutine, C<@_> is the default array for
392that subroutine. Inside a subroutine, C<@_> is the default array for
354the array operators C<push>, C<pop>, C<shift>, and C<unshift>.
393the array operators C<pop> and C<shift>.
355394
356395=end original
357396
358397サブルーチンに入るときには、配列 C<@_> はサブルーチンに渡された
359398パラメータです。
360サブルーチンの内部では、C<@_> は配列演算子 C<push>, C<pop>, C<shift>,
399サブルーチンの内部では、C<@_> は配列演算子 C<push>, C<shift>
361C<unshift> のデフォルト配列です。
400デフォルト配列です。
362401
363402=begin original
364403
365404See L<perlsub>.
366405
367406=end original
368407
369408L<perlsub> を参照して下さい。
370409
371410=item $LIST_SEPARATOR
372411
373412=item $"
374413X<$"> X<$LIST_SEPARATOR>
375414
376415=begin original
377416
378417When an array or an array slice is interpolated into a double-quoted
379418string or a similar context such as C</.../>, its elements are
380separated by this value. Default is a space. For example, this:
419separated by this value. Default is a space. For example, this:
381420
382421=end original
383422
384423配列や配列スライスがダブルクォートされた文字列あるいは C</.../> のような
385424同様のコンテキスト展開されたとき、その要素はこの値で分割されます。
386425デフォルトは空白です。
387426例えば、以下のものは:
388427
389 print "The array is: @array\n";
428 print "The array is: @array\n";
390429
391430=begin original
392431
393432is equivalent to this:
394433
395434=end original
396435
397436以下と等価です:
398437
399 print "The array is: " . join($", @array) . "\n";
438 print "The array is: " . join($", @array) . "\n";
400439
401440=begin original
402441
403442Mnemonic: works in double-quoted context.
404443
405444=end original
406445
407446記憶法: ダブルクォートされた内容に対して動作します。
408447
409448=item $PROCESS_ID
410449
411450=item $PID
412451
413452=item $$
414453X<$$> X<$PID> X<$PROCESS_ID>
415454
416455=begin original
417456
418The process number of the Perl running this script. You should
457The process number of the Perl running this script. Though you I<can> set
419consider this variable read-only, although it will be altered
458this variable, doing so is generally discouraged, although it can be
459invaluable for some testing purposes. It will be reset automatically
420460across C<fork()> calls.
421461
422462=end original
423463
424スクリプトを実行している Perl のプロセス番号です。
464このスクリプトを実行している Perl のプロセス番号です。
425この変数は read-only と考えるべきですが、
465この変数に値を設定することI<可能> ですが、そうすることは一般的に
426C<fork()> 呼び出しによって値変わります。
466非推奨です;かしこれは一部のテストの目的には計り知れない価値があります。
467C<fork()> 呼び出しがあると自動的にリセットされます。
427468
428469=begin original
429470
430Note for Linux users: on Linux, the C functions C<getpid()> and
471Note for Linux and Debian GNU/kFreeBSD users: Before Perl v5.16.0 perl
431C<getppid()> return different values from different threads. In order to
472would emulate POSIX semantics on Linux systems using LinuxThreads, a
432be portable, this behavior is not reflected by C<$$>, whose value remains
473partial implementation of POSIX Threads that has since been superseded
433consistent across threads. If you want to call the underlying C<getpid()>,
474by the Native POSIX Thread Library (NPTL).
434you may use the CPAN module C<Linux::Pid>.
435475
436476=end original
437477
438Linux ユーザーへの注意: Linux では、C 関数 C<getpid()> C<getppid()> は
478Linux および Debian GNU/kFreeBSD ユーザーに対する注意: Perl v5.16.0 より
439スレッドが異なると異なた値返します。
479前では perl は LinuxThreads を使て Linux システムで POSIX の意味論
440移植性のめに、の振る舞いC<$$> には反映されず、こ値はスレッド間
480エミュレートしていまし; POSIX Threads 部分的な実装
441一貫してい
481Native POSIX Thread Library (NPTL) で置き換えられした
442もし内在する C<getpid()> を呼び出したい場合は、CPAN モジュール
443C<Linux::Pid> が使えます。
444482
445483=begin original
446484
447Mnemonic: same as shells.
485LinuxThreads is now obsolete on Linux, and caching C<getpid()>
486like this made embedding perl unnecessarily complex (since you'd have
487to manually update the value of $$), so now C<$$> and C<getppid()>
488will always return the same values as the underlying C library.
448489
449490=end original
450491
451記憶法: シェルと同じ。
492LinuxThreads は Linux では古いもので、このように C<getpid()> を
493キャッシュすると組み込み perl が不必要に複雑になります ($$ の値を手動で
494更新する必要があるからです); それで今では C<$$> と C<getppid()> は常に
495基礎となる C ライブラリと同じ値を返します。
452496
453=item $REAL_GROUP_ID
454
455=item $GID
456
457=item $(
458X<$(> X<$GID> X<$REAL_GROUP_ID>
459
460497=begin original
461498
462The real gid of this process. If you are on a machine that supports
499Debian GNU/kFreeBSD systems also used LinuxThreads up until and
463membership in multiple groups simultaneously, gives a space separated
500including the 6.0 release, but after that moved to FreeBSD thread
464list of groups you are in. The first number is the one returned by
501semantics, which are POSIX-like.
465C<getgid()>, and the subsequent ones by C<getgroups()>, one of which may be
466the same as the first number.
467502
468503=end original
469504
470本プロセの実 gid を示します。
505Debian GNU/kFreeBSD シテムは 6.0 リリースまで LinuxThreads
471同時に複数グループに所属できるマシンで、所属するグループをペースで
506使っていましたが、そ POSIX 風の FreeBSD レッドの意味論に
472区切ったリストが得られ
507移行しした
473最初の数値は、C<getgid()> で返されるものです。
474その後に C<getgroups()> が返す値が続き、その中の 1 つは、
475最初の値と同じかもしれません。
476508
477509=begin original
478510
479However, a value assigned to C<$(> must be a single number used to
511To see if your system is affected by this discrepancy check if
480set the real gid. So the value given by C<$(> should I<not> be assigned
512C<getconf GNU_LIBPTHREAD_VERSION | grep -q NPTL> returns a false
481back to C<$(> without being forced numeric, such as by adding zero. Note
513value. NTPL threads preserve the POSIX semantics.
482that this is different to the effective gid (C<$)>) which does take a
483list.
484514
485515=end original
486516
487しかし、C<$(> に代入され値は実際 gid に設定された値
517あなたのシステムがこ非一貫性の影響を受けるかどうかを調べるには、
488一つでなければなりません。
518C<getconf GNU_LIBPTHREAD_VERSION | grep -q NPTL> が偽を返すかどうかを
489従っ、 C<$(> で与えられた値はゼロを足すことによって
519チェックしください。
490数値化することなく C<$(> に書き戻すべきでありせん
520NTPL スレッド POSIX の意味論を保存し
491これはリストが得られる実行 GID (C<$)>) とは違うことに注意してください。
492521
493522=begin original
494523
495You can change both the real gid and the effective gid at the same
524Mnemonic: same as shells.
496time by using C<POSIX::setgid()>. Changes to C<$(> require a check to C<$!>
497to detect any possible errors after an attempted change.
498525
499526=end original
500527
501C<POSIX::setgid()> を使って、実 GID 実効 GID の両方を時に変更できます
528記憶法: シェルと同
502C<$(> を変更した場合は、変更しようとしたときに起こりうるエラーを検出するために
503C<$!> をチェックする必要があります。
504529
505=begin original
506
507Mnemonic: parentheses are used to I<group> things. The real gid is the
508group you I<left>, if you're running setgid.
509
510=end original
511
512記憶法: 括弧は、I<グループ化>に使われます。
513setgid で実行中であれば、実 gid は I<left> した、つまり離れたグループです。
514
515=item $EFFECTIVE_GROUP_ID
516
517=item $EGID
518
519=item $)
520X<$)> X<$EGID> X<$EFFECTIVE_GROUP_ID>
521
522=begin original
523
524The effective gid of this process. If you are on a machine that
525supports membership in multiple groups simultaneously, gives a space
526separated list of groups you are in. The first number is the one
527returned by C<getegid()>, and the subsequent ones by C<getgroups()>,
528one of which may be the same as the first number.
529
530=end original
531
532本プロセスの実効 gid を示します。
533同時に複数のグループに所属できるマシンでは、
534所属するグループをスペースで区切ったリストが得られます。
535最初の数値は、C<getegid()> で返されるものです。
536その後に C<getgroups()> が返す値が続き、その中の 1 つは、
537最初の値と同じかもしれません。
538
539=begin original
540
541Similarly, a value assigned to C<$)> must also be a space-separated
542list of numbers. The first number sets the effective gid, and
543the rest (if any) are passed to C<setgroups()>. To get the effect of an
544empty list for C<setgroups()>, just repeat the new effective gid; that is,
545to force an effective gid of 5 and an effectively empty C<setgroups()>
546list, say C< $) = "5 5" >.
547
548=end original
549
550同様に、C<$)> へ代入する値はスペースで区切られた数値の
551リストでなければなりません。
552最初の数値は実効 gid を設定し、残りの数値は(もしあれば) C<setgroups()> に
553渡されます。
554C<setgroups()> に空リストを渡したい場合は、単に新しい実効 gid を
555繰り返してください。
556つまり、実効 gid を 5 にして、C<setgroups()> に空リストを渡したい場合は、
557C< $) = "5 5" > としてください。
558
559=begin original
560
561You can change both the effective gid and the real gid at the same
562time by using C<POSIX::setgid()> (use only a single numeric argument).
563Changes to C<$)> require a check to C<$!> to detect any possible errors
564after an attempted change.
565
566=end original
567
568C<POSIX::setgid()> を使って、実効 GID と実 GID を同時に変更できます。
569(1 つの数値引数だけが使えます)。
570C<$)> を変更した場合は、変更時に起こりうるエラーを検出するために C<$!> の
571チェックが必要です。
572
573=begin original
574
575C<< $< >>, C<< $> >>, C<$(> and C<$)> can be set only on
576machines that support the corresponding I<set[re][ug]id()> routine. C<$(>
577and C<$)> can be swapped only on machines supporting C<setregid()>.
578
579=end original
580
581C<< $< >>, C<< $> >>, C<$(>, C<$)> は、実行するマシンで、
582対応する I<set[re][ug]id()> ルーティンがサポートされているときにのみ
583設定可能です。
584C<$(> と C<$)> の交換は、
585C<setregid()> がサポートされているマシンでのみ可能です。
586
587=begin original
588
589Mnemonic: parentheses are used to I<group> things. The effective gid
590is the group that's I<right> for you, if you're running setgid.
591
592=end original
593
594記憶法: 括弧は、I<グループ化>に使われます。
595setgid で実行中であれば、実効 gid は right な、つまり正しいグループです。
596
597530=item $PROGRAM_NAME
598531
599532=item $0
600533X<$0> X<$PROGRAM_NAME>
601534
602535=begin original
603536
604537Contains the name of the program being executed.
605538
606539=end original
607540
608541実行されているプログラムの名前を示します。
609542
610543=begin original
611544
612545On some (but not all) operating systems assigning to C<$0> modifies
613the argument area that the C<ps> program sees. On some platforms you
546the argument area that the C<ps> program sees. On some platforms you
614547may have to use special C<ps> options or a different C<ps> to see the
615changes. Modifying the C<$0> is more useful as a way of indicating the
548changes. Modifying the C<$0> is more useful as a way of indicating the
616549current program state than it is for hiding the program you're
617550running.
618551
619552=end original
620553
621554一部の(しかし全てではありません)オペレーティングシステムでは
622555C<$0> に代入を行なうことで B<ps> プログラムが見る引数エリアを修正します。
623556プラットフォームによっては、この変更を見るために 特殊な C<ps> オプションや、
624557他の C<ps> を使う必要があるものもあります。
625558C<$0> の修正は、実行しているプログラムを隠すよりは、
626559実行中のプログラムの状態を表示するときに、使うとよいでしょう。
627560
628561=begin original
629562
630563Note that there are platform-specific limitations on the maximum
631length of C<$0>. In the most extreme case it may be limited to the
564length of C<$0>. In the most extreme case it may be limited to the
632565space occupied by the original C<$0>.
633566
634567=end original
635568
636569C<$0> の最大長にはプラットフォーム固有の制限があることに注意してください。
637570最も極端な場合では、元の C<$0> で占められているサイズに制限されます。
638571
639572=begin original
640573
641574In some platforms there may be arbitrary amount of padding, for
642575example space characters, after the modified name as shown by C<ps>.
643576In some platforms this padding may extend all the way to the original
644577length of the argument area, no matter what you do (this is the case
645578for example with Linux 2.2).
646579
647580=end original
648581
649582プラットフォームによっては、任意の量のパッディングがある場合があります;
650583例えば、C<ps> で見られる修正された名前の後の空白文字です。
651584プラットフォームによっては、このパッディングは、あなたが何をしたかに
652585関わらず、元の引数のエリア全体に拡張されるものもあります
653586(例えば、これは Linux 2.2 の場合です)。
654587
655588=begin original
656589
657590Note for BSD users: setting C<$0> does not completely remove "perl"
658from the ps(1) output. For example, setting C<$0> to C<"foobar"> may
591from the ps(1) output. For example, setting C<$0> to C<"foobar"> may
659592result in C<"perl: foobar (perl)"> (whether both the C<"perl: "> prefix
660593and the " (perl)" suffix are shown depends on your exact BSD variant
661and version). This is an operating system feature, Perl cannot help it.
594and version). This is an operating system feature, Perl cannot help it.
662595
663596=end original
664597
665598BSD ユーザーへの注意: C<$0> に値をセットしても、ps(1) の出力から
666599完全に "perl" の文字列は取り除かれません。
667600例えば、C<$0> に C<"foobar"> と設定すると、C<"perl: foobar (perl)"> という
668601結果になります
669602(C<"perl: "> 接頭辞と" (perl)" 接尾辞が表示されるかどうかは 、正確な
670603BSD の種類とバージョンに依存します)。
671604これはオペレーティングシステムの機能で、Perl は何もできません。
672605
673606=begin original
674607
675608In multithreaded scripts Perl coordinates the threads so that any
676609thread may modify its copy of the C<$0> and the change becomes visible
677to ps(1) (assuming the operating system plays along). Note that
610to ps(1) (assuming the operating system plays along). Note that
678611the view of C<$0> the other threads have will not change since they
679612have their own copies of it.
680613
681614=end original
682615
683616マルチスレッドスクリプトでは、どのスレッドも自身の C<$0> のコピーを
684617変更できて、その変更が(OS が対応しているとして) ps(1) で見えるように、
685618Perl がスレッドを調整します。
686619他のスレッドが持っている C<$0> の見え方は(各自が自身のコピーを
687620持っているので)変わらないことに注意してください。
688621
689622=begin original
690623
691624If the program has been given to perl via the switches C<-e> or C<-E>,
692625C<$0> will contain the string C<"-e">.
693626
694627=end original
695628
696629プログラムが perl に C<-e> または C<-E> オプション経由で与えられた場合、
697630C<$0> には文字列 C<"-e"> を含みます。
698631
699632=begin original
700633
701On Linux as of perl 5.14 the legacy process name will be set with
634On Linux as of perl v5.14.0 the legacy process name will be set with
702635C<prctl(2)>, in addition to altering the POSIX name via C<argv[0]> as
703perl has done since version 4.000. Now system utilities that read the
636perl has done since version 4.000. Now system utilities that read the
704637legacy process name such as ps, top and killall will recognize the
705name you set when assigning to C<$0>. The string you supply will be
638name you set when assigning to C<$0>. The string you supply will be
706639cut off at 16 bytes, this is a limitation imposed by Linux.
707640
708641=end original
709642
710Linux では perl 5.14 以降、perl がバージョン 4.000 以降行っていた
643Linux では perl v5.14.0 以降、perl がバージョン 4.000 以降行っていた
711644C<argv[0]> 経由での POSIX 名の置き換えに加えて、
712645レガシープロセス名は C<prctl(2)> で設定されます。
713646今では ps, top, killall のようにレガシープロセス名を読むユーティリティは
714647C<$0> に代入することに設定される名前を認識します。
715648指定した文字列は 16 バイトに切り詰められます; これは Linux による
716649制限です。
717650
718651=begin original
719652
653Wide characters are invalid in C<$0> values. For historical reasons,
654though, Perl accepts them and encodes them to UTF-8. When this
655happens a wide-character warning is triggered.
656
657=end original
658
659ワイド文字は C<$0> の値としては不正です。
660しかし、歴史的な理由により、Perl はこれを受け入れて、UTF-8 に
661エンコードします。
662これが起きると、wide-character 警告が引き起こされます。
663
664=begin original
665
720666Mnemonic: same as B<sh> and B<ksh>.
721667
722668=end original
723669
724670記憶法: B<sh> や B<ksh> と同じ。
725671
726=item $SUBSCRIPT_SEPARATOR
672=item $REAL_GROUP_ID
727673
728=item $SUBSEP
674=item $GID
729675
730=item $;
676=item $(
731X<$;> X<$SUBSEP> X<SUBSCRIPT_SEPARATOR>
677X<$(> X<$GID> X<$REAL_GROUP_ID>
732678
733679=begin original
734680
735The subscript separator for multidimensional array emulation. If you
681The real gid of this process. If you are on a machine that supports
736refer to a hash element as
682membership in multiple groups simultaneously, gives a space separated
683list of groups you are in. The first number is the one returned by
684C<getgid()>, and the subsequent ones by C<getgroups()>, one of which may be
685the same as the first number.
737686
738687=end original
739688
740多次元配列エミュレートのための添え字の区切文字
689本プロセス実 gid を示します
741ハッシュ要素
690同時に複数グループに所属できるマシンでは、所属するグループスペースで
691区切ったリストが得られます。
692最初の数値は、C<getgid()> で返されるものです; その後に C<getgroups()> が
693返す値が続き、その中の 1 つは、最初の値と同じかもしれません。
742694
743 $foo{$a,$b,$c}
744
745695=begin original
746696
747it really means
697However, a value assigned to C<$(> must be a single number used to
698set the real gid. So the value given by C<$(> should I<not> be assigned
699back to C<$(> without being forced numeric, such as by adding zero. Note
700that this is different to the effective gid (C<$)>) which does take a
701list.
748702
749703=end original
750704
751のようにて参照すると、実際に
705かしC<$(> に代入された値は実際の gid 設定された値の
706一つでなければなりません。
707従って、 C<$(> で与えられた値はゼロを足すことによって
708数値化することなく C<$(> に書き戻すべきではありません。
709これはリストが得られる実行 GID (C<$)>) とは違うことに注意してください。
752710
753 $foo{join($;, $a, $b, $c)}
711=begin original
754712
713You can change both the real gid and the effective gid at the same
714time by using C<POSIX::setgid()>. Changes
715to C<$(> require a check to C<$!>
716to detect any possible errors after an attempted change.
717
718=end original
719
720C<POSIX::setgid()> を使って、実 GID と実効 GID の両方を同時に変更できます。
721C<$(> を変更した場合は、変更しようとしたときに起こりうるエラーを検出するために
722C<$!> をチェックする必要があります。
723
755724=begin original
756725
757But don't put
726Mnemonic: parentheses are used to I<group> things. The real gid is the
727group you I<left>, if you're running setgid.
758728
759729=end original
760730
761という意味なります。
731記憶法: 括弧は、I<グループ化>使われます。
762かし
732setgid で実行中であれば、実 gid は I<left> つまり離れたグループです。
763733
764 @foo{$a,$b,$c} # a slice--note the @
734=item $EFFECTIVE_GROUP_ID
765735
736=item $EGID
737
738=item $)
739X<$)> X<$EGID> X<$EFFECTIVE_GROUP_ID>
740
766741=begin original
767742
768which means
743The effective gid of this process. If you are on a machine that
744supports membership in multiple groups simultaneously, gives a space
745separated list of groups you are in. The first number is the one
746returned by C<getegid()>, and the subsequent ones by C<getgroups()>,
747one of which may be the same as the first number.
769748
770749=end original
771750
772てはいけせん
751本プロセスの実効 gid を示しま
773これは以下意味なりま
752同時に複数グループ所属できるマシンでは、所属るグループをスペースで
753区切ったリストが得られます。
754最初の数値は、C<getegid()> で返されるものです; その後に C<getgroups()> が
755返す値が続き、その中の 1 つは、最初の値と同じかもしれません。
774756
775 ($foo{$a},$foo{$b},$foo{$c})
757=begin original
776758
759Similarly, a value assigned to C<$)> must also be a space-separated
760list of numbers. The first number sets the effective gid, and
761the rest (if any) are passed to C<setgroups()>. To get the effect of an
762empty list for C<setgroups()>, just repeat the new effective gid; that is,
763to force an effective gid of 5 and an effectively empty C<setgroups()>
764list, say C< $) = "5 5" >.
765
766=end original
767
768同様に、C<$)> へ代入する値はスペースで区切られた数値の
769リストでなければなりません。
770最初の数値は実効 gid を設定し、残りの数値は(もしあれば) C<setgroups()> に
771渡されます。
772C<setgroups()> に空リストを渡したい場合は、単に新しい実効 gid を
773繰り返してください; つまり、実効 gid を 5 にして、C<setgroups()> に空リストを
774渡したい場合は、C< $) = "5 5" > としてください。
775
777776=begin original
778777
779Default is "\034", the same as SUBSEP in B<awk>. If your keys contain
778You can change both the effective gid and the real gid at the same
780binary data there might not be any safe value for C<$;>.
779time by using C<POSIX::setgid()> (use only a single numeric argument).
780Changes to C<$)> require a check to C<$!> to detect any possible errors
781after an attempted change.
781782
782783=end original
783784
784デフォルトは "\034" で、C<awk> SUBSEP と同です
785C<POSIX::setgid()> を使って、実効 GID実 GID を時に変更きま
785使おうとしている key の値がバイナリのデータを含むならば、
786(1 引数だけ使えます)。
786C<$;> に設定する安全な値などないこと
787C<$)> を変更した場合、変更時起こうるエラーを検出るために C<$!> の
788チェックが必要です。
787789
788790=begin original
789791
790Consider using "real" multidimensional arrays as described
792C<< $< >>, C<< $> >>, C<$(> and C<$)> can be set only on
791in L<perllol>.
793machines that support the corresponding I<set[re][ug]id()> routine. C<$(>
794and C<$)> can be swapped only on machines supporting C<setregid()>.
792795
793796=end original
794797
795L<perllol> で記述してい「本物の」多次元配列を使うようにしてください。
798C<< $< >>, C<< $> >>, C<$(>, C<$)> は、実行すマシンで、
799対応する I<set[re][ug]id()> ルーティンがサポートされているときにのみ
800設定可能です。
801C<$(> と C<$)> の交換は、
802C<setregid()> がサポートされているマシンでのみ可能です。
796803
797804=begin original
798805
799Mnemonic: comma (the syntactic subscript separator) is a semi-semicolon.
806Mnemonic: parentheses are used to I<group> things. The effective gid
807is the group that's I<right> for you, if you're running setgid.
800808
801809=end original
802810
803記憶法: コンマ (構文上の添え字区切り文字)
811記憶法: 括弧、I<グループ化>に使われます。
804セミ−セミコロンです。
812setgid で実行中であれば、実効 gid は right 、つまり正しいグループです。
805813
806814=item $REAL_USER_ID
807815
808816=item $UID
809817
810818=item $<
811819X<< $< >> X<$UID> X<$REAL_USER_ID>
812820
813821=begin original
814822
815The real uid of this process. You can change both the real uid and the
823The real uid of this process. You can change both the real uid and the
816effective uid at the same time by using C<POSIX::setuid()>. Since
824effective uid at the same time by using C<POSIX::setuid()>. Since
817825changes to C<< $< >> require a system call, check C<$!> after a change
818826attempt to detect any possible errors.
819827
820828=end original
821829
822830本プロセスの実 uid を示します。
823831C<POSIX::setuid()> を使って、実効 UID と実 UID を同時に変更できます。
824832C<< $< >> の変更にはシステムコールが必要なので、起こりうるエラーを
825833検出するために C<$!> のチェックが必要です。
826834
827835=begin original
828836
829837Mnemonic: it's the uid you came I<from>, if you're running setuid.
830838
831839=end original
832840
833841記憶法: setuid で実行中であれば、そこ「から」来た uid です。
834842
835843=item $EFFECTIVE_USER_ID
836844
837845=item $EUID
838846
839847=item $>
840848X<< $> >> X<$EUID> X<$EFFECTIVE_USER_ID>
841849
842850=begin original
843851
844The effective uid of this process. For example:
852The effective uid of this process. For example:
845853
846854=end original
847855
848856本プロセスの実効 uid を示します。
849857例えば:
850858
851 $< = $>; # set real to effective uid
859=begin original
852 ($<,$>) = ($>,$<); # swap real and effective uids
853860
861 $< = $>; # set real to effective uid
862 ($<,$>) = ($>,$<); # swap real and effective uids
863
864=end original
865
866 $< = $>; # 実 uid に実効 uid を設定
867 ($<,$>) = ($>,$<); # 実 uid と実効 uid を交換
868
854869=begin original
855870
856871You can change both the effective uid and the real uid at the same
857time by using C<POSIX::setuid()>. Changes to C<< $> >> require a check
872time by using C<POSIX::setuid()>. Changes to C<< $> >> require a check
858873to C<$!> to detect any possible errors after an attempted change.
859874
860875=end original
861876
862877C<POSIX::setuid()> を使って、実効 UID と実 UID を同時に変更できます。
863878C<< $> >> を変更した場合は、変更時に起こりうるエラーを検出するために
864879C<$!> のチェックが必要です。
865880
866881=begin original
867882
868883C<< $< >> and C<< $> >> can be swapped only on machines
869884supporting C<setreuid()>.
870885
871886=end original
872887
873888C<< $< >> と C<< $> >> の交換は、C<setreuid()> をサポートしている
874889マシンでのみ可能です。
875890
876891=begin original
877892
878893Mnemonic: it's the uid you went I<to>, if you're running setuid.
879894
880895=end original
881896
882897記憶法: setuid で実行中であれば、そこ I<へ> 行く uid です。
883898
884=item $a
899=item $SUBSCRIPT_SEPARATOR
885900
886=item $b
901=item $SUBSEP
887X<$a> X<$b>
888902
889=begin original
903=item $;
904X<$;> X<$SUBSEP> X<SUBSCRIPT_SEPARATOR>
890905
891Special package variables when using C<sort()>, see L<perlfunc/sort>.
892Because of this specialness C<$a> and C<$b> don't need to be declared
893(using C<use vars>, or C<our()>) even when using the C<strict 'vars'>
894pragma. Don't lexicalize them with C<my $a> or C<my $b> if you want to
895be able to use them in the C<sort()> comparison block or function.
896
897=end original
898
899C<sort()> を使うときの特殊パッケージ変数です; L<perlfunc/sort> を
900参照してください。
901この特殊性により、C<$a> と C<$b> は、たとえ C<strict 'vars'> プラグマを
902使っているときでも (C<use vars> や C<our()> を使って) 宣言する必要が
903ありません。
904これを C<sort()> 比較ブロックや関数で使えるようにしたい場合は、
905C<my $a> や C<my $b> としてレキシカル化しないでください。
906
907=item $COMPILING
908
909=item $^C
910X<$^C> X<$COMPILING>
911
912906=begin original
913907
914The current value of the flag associated with the B<-c> switch.
908The subscript separator for multidimensional array emulation. If you
915Mainly of use with B<-MO=...> to allow code to alter its behavior
909refer to a hash element as
916when being compiled, such as for example to C<AUTOLOAD> at compile
917time rather than normal, deferred loading. Setting
918C<$^C = 1> is similar to calling C<B::minus_c>.
919910
920911=end original
921912
922B<-c> スイッチに関連付けられ現在値です
913多次元配列のエミュレートの添え字の区切文字
923主に B<-MO=...> と共に用いられ、例えば C<AUTOLOAD> を通常遅延ロードでは
914ハッシュ要素を
924なくコンパイル時に実行するといった、コンパイル時の振る舞いを
925変えるために用います。
926C<$^C = 1> に設定することは C<B::minus_c> を呼び出すのと似ています。
927915
928=begin original
916 $foo{$x,$y,$z}
929917
930This variable was added in Perl 5.6.
931
932=end original
933
934この変数は Perl 5.6 で追加されました。
935
936=item $DEBUGGING
937
938=item $^D
939X<$^D> X<$DEBUGGING>
940
941918=begin original
942919
943The current value of the debugging flags. May be read or set. Like its
920it really means
944command-line equivalent, you can use numeric or symbolic values, eg
945C<$^D = 10> or C<$^D = "st">.
946921
947922=end original
948923
949デバッグフラグ現在の値を示します
924ようにて参照すると、実際には以下のようになります
950読み書き可能です。
951コマンドラインによる等価な機能と同様に、数値とシンボル値が使えます
952(例: C<$^D = 10> または C<$^D = "st">)。
953925
954=begin original
926 $foo{join($;, $x, $y, $z)}
955927
956Mnemonic: value of B<-D> switch.
957
958=end original
959
960記憶法: B<-D> スイッチの値。
961
962=item ${^ENCODING}
963X<${^ENCODING}>
964
965928=begin original
966929
967The I<object reference> to the C<Encode> object that is used to convert
930But don't put
968the source code to Unicode. Thanks to this variable your Perl script
969does not have to be written in UTF-8. Default is I<undef>. The direct
970manipulation of this variable is highly discouraged.
971931
972932=end original
973933
974ソースコードを Unicode に変換するために使われる C<Encode> オブジェクトへ
934しかし、以下ようにしてはいけません
975I<オブジェクトリファレンス> 。
976この変数のおかげで、Perl スクリプトを UTF-8 で書く必要がありません。
977デフォルトは I<undef> です。
978この変数を直接操作することはとても推奨できません。
979935
980936=begin original
981937
982This variable was added in Perl 5.8.2.
938 @foo{$x,$y,$z} # a slice--note the @
983939
984940=end original
985941
986この変数は Perl 5.8.2 で追加されました。
942 @foo{$x,$y,$z} # スライス -- @ に注意
987943
988=item %ENV
989X<%ENV>
990
991944=begin original
992945
993The hash C<%ENV> contains your current environment. Setting a
946which means
994value in C<ENV> changes the environment for any child processes
995you subsequently C<fork()> off.
996947
997948=end original
998949
999ハッシュ C<%ENV> に、そ時点の環境変数が設定されています
950これ以下意味になります
1000C<ENV> に値を設定することで、
1001以後に C<fork()> した子プロセスの環境変数を変更します。
1002951
1003=item $SYSTEM_FD_MAX
952 ($foo{$x},$foo{$y},$foo{$z})
1004953
1005=item $^F
1006X<$^F> X<$SYSTEM_FD_MAX>
1007
1008954=begin original
1009955
1010The maximum system file descriptor, ordinarily 2. System file
956Default is "\034", the same as SUBSEP in B<awk>. If your keys contain
1011descriptors are passed to C<exec()>ed processes, while higher file
957binary data there might not be any safe value for C<$;>.
1012descriptors are not. Also, during an C<open()>, system file descriptors are
1013preserved even if the C<open()> fails (ordinary file descriptors are
1014closed before the C<open()> is attempted). The close-on-exec
1015status of a file descriptor will be decided according to the value of
1016C<$^F> when the corresponding file, pipe, or socket was opened, not the
1017time of the C<exec()>.
1018958
1019959=end original
1020960
1021システムが使用するァイ記述子の最大値を示し、通常2 です。
961"\034" で、C<awk> の SUBSEP と同じです。
1022システムファイル記述子は、C<exec()> されたプロセスに渡されますが、
962使おうとしている key の値バイナリのデータを含むならば
1023それ以降のファイル記述子渡されせん
963C<$;> に設定する安全な値などないことになり
1024また、C<open()> の実行中は、システムファイル記述子は、
1025たとえ C<open()> が失敗しても、保存されます。
1026(通常のファイル記述子は、C<open()> が実行される前にクローズされます。)
1027ファイル記述子の close-on-exec のステータスは、C<exec()> 時ではなく、
1028対応するファイル、パイプソケットの open 時の C<$^F> の値によって
1029決められます。
1030964
1031=item @F
1032X<@F>
1033
1034965=begin original
1035966
1036The array C<@F> contains the fields of each line read in when autosplit
967Consider using "real" multidimensional arrays as described
1037mode is turned on. See L<perlrun> for the B<-a> switch. This array
968in L<perllol>.
1038is package-specific, and must be declared or given a full package name
1039if not in package main when running under C<strict 'vars'>.
1040969
1041970=end original
1042971
1043自動 split モードが有効場合、配列 C<@F> は読み込ん行のフィールドを
972L<perllol> で記述している「本物」多次元配列を使うようしてくさい。
1044含みます。
1045B<-a> オプションについては L<perlrun> を参照してください。
1046この配列はパッケージ固有であり、もし C<strict 'vars'> で実行していて
1047パッケージ main 以外の場合は完全なパッケージ名で定義したり与えたり
1048しなければなりません。
1049973
1050=item ${^GLOBAL_PHASE}
1051X<${^GLOBAL_PHASE}>
1052
1053974=begin original
1054975
1055The current phase of the perl interpreter.
976Mnemonic: comma (the syntactic subscript separator) is a semi-semicolon.
1056977
1057978=end original
1058979
1059perl タプリタ現在フェーズ
980記憶法: マ (構文上添え字区切り文字) はセミ-セミコロンなです
1060981
1061=begin original
982=item $a
1062983
1063Possible values are:
984=item $b
985X<$a> X<$b>
1064986
1065=end original
1066
1067取り得る値は:
1068
1069=over 8
1070
1071=item CONSTRUCT
1072
1073987=begin original
1074988
1075The C<PerlInterpreter*> is being constructed via C<perl_construct>. This
989Special package variables when using C<sort()>, see L<perlfunc/sort>.
1076value is mostly there for completeness and for use via the
990Because of this specialness C<$a> and C<$b> don't need to be declared
1077underlying C variable C<PL_phase>. It's not really possible for Perl
991(using C<use vars>, or C<our()>) even when using the C<strict 'vars'>
1078code to be executed unless construction of the interpreter is
992pragma. Don't lexicalize them with C<my $a> or C<my $b> if you want to
1079finished.
993be able to use them in the C<sort()> comparison block or function.
1080994
1081995=end original
1082996
1083C<PerlInterpreter*> C<perl_construct> で構築されます。
997C<sort()> を使うときの特殊パッケージ変数です; L<perlfunc/sort>
1084この変数はほとんど完全性のためと、基礎となっている C 変数
998参照しくださ
1085C<PL_phase> 経由での使用のめに存在しています。
999この特殊性により、C<$a> と C<$b> は、とえ C<strict 'vars'> プラグマを
1086実際にはインタプリタの構築が完了しな限り Perl コード
1000使ってるときでも (C<use vars> や C<our()> 使って) 宣言する必要が
1087実行することはできません。
1001ありません。
1002これを C<sort()> 比較ブロックや関数で使えるようにしたい場合は、
1003C<my $a> や C<my $b> としてレキシカル化しないでください。
10881004
1089=item START
1005=item %ENV
1006X<%ENV>
10901007
10911008=begin original
10921009
1093This is the global compile-time. That includes, basically, every
1010The hash C<%ENV> contains your current environment. Setting a
1094C<BEGIN> block executed directly or indirectly from during the
1011value in C<ENV> changes the environment for any child processes
1095compile-time of the top-level program.
1012you subsequently C<fork()> off.
10961013
10971014=end original
10981015
1099これコンパイルにグローバルです。
1016ハッシュ C<%ENV> に、その点の環境変数が設定されています。
1100これは基本的に、直接実行されたり、トップレベルプログラムの
1017C<ENV> 値を設定することで
1101コンパイル時の間間接的に実行される全ての C<BEGIN> す。
1018以後に C<fork()> した子プロセスの環境変数を変更します。
11021019
11031020=begin original
11041021
1105This phase is not called "BEGIN" to avoid confusion with
1022As of v5.18.0, both keys and values stored in C<%ENV> are stringified.
1106C<BEGIN>-blocks, as those are executed during compile-time of any
1107compilation unit, not just the top-level program. A new, localised
1108compile-time entered at run-time, for example by constructs as
1109C<eval "use SomeModule"> are not global interpreter phases, and
1110therefore aren't reflected by C<${^GLOBAL_PHASE}>.
11111023
11121024=end original
11131025
1114C<BEGIN> ブロックとの混乱を避けるため、このフェ名前 "BEGIN" では
1026v5.18.0 から、C<%ENV> に補完されたキと値両方文字列化されます。
1115ありません; これらは単にトップレベルプログラムではなく、任意のコンパイル
1116ユニットのコンパイル中に実行されます。
1117例えば C<eval "use SomeModule"> のように、実行時に入った
1118新しいローカル化されたコンパイル時はグローバルなインタプリタフェーズではなく、
1119従って C<${^GLOBAL_PHASE}> に反映されません。
11201027
1121=item CHECK
1028 my $foo = 1;
1029 $ENV{'bar'} = \$foo;
1030 if( ref $ENV{'bar'} ) {
1031 say "Pre 5.18.0 Behaviour";
1032 } else {
1033 say "Post 5.18.0 Behaviour";
1034 }
11221035
11231036=begin original
11241037
1125Execution of any C<CHECK> blocks.
1038Previously, only child processes received stringified values:
11261039
11271040=end original
11281041
1129C<CHECK> ブック実行。
1042以前は、子プセスみが文字列化された値を受け取っていました:
11301043
1131=item INIT
1044 my $foo = 1;
1045 $ENV{'bar'} = \$foo;
11321046
1133=begin original
1047 # Always printed 'non ref'
1048 system($^X, '-e',
1049 q/print ( ref $ENV{'bar'} ? 'ref' : 'non ref' ) /);
11341050
1135Similar to "CHECK", but for C<INIT>-blocks, not C<CHECK> blocks.
1136
1137=end original
1138
1139"CHECK" と似ていますが、C<CHECK> ブロックではなく C<INIT> ブロック。
1140
1141=item RUN
1142
11431051=begin original
11441052
1145The main run-time, i.e. the execution of C<PL_main_root>.
1053This happens because you can't really share arbitrary data structures with
1054foreign processes.
11461055
11471056=end original
11481057
1149メイン実行; つまり C<PL_main_root> の実行。
1058これは、外部プロセスと本当に任意データ構造を共有することができないために
1059起きます。
11501060
1151=item END
1061=item $OLD_PERL_VERSION
11521062
1153=begin original
1063=item $]
1064X<$]> X<$OLD_PERL_VERSION>
11541065
1155Execution of any C<END> blocks.
1156
1157=end original
1158
1159C<END> ブロックの実行。
1160
1161=item DESTRUCT
1162
11631066=begin original
11641067
1165Global destruction.
1068The revision, version, and subversion of the Perl interpreter, represented
1069as a decimal of the form 5.XXXYYY, where XXX is the version / 1e3 and YYY
1070is the subversion / 1e6. For example, Perl v5.10.1 would be "5.010001".
11661071
11671072=end original
11681073
1169グローバルなデストラク
10745.XXXYYY 型式の小数で表現される Perl インプリタの
1075revision, version, subversion
1076(XXX は version / 1e3、 YYY は subversion / 1e6)。
1077例えば、、Perl v5.10.1 は "5.010001" です。
11701078
1171=back
1172
11731079=begin original
11741080
1175Also note that there's no value for UNITCHECK-blocks. That's because
1081This variable can be used to determine whether the Perl interpreter
1176those are run for each compilation unit individually, and therefore is
1082executing a script is in the right range of versions:
1177not a global interpreter phase.
11781083
11791084=end original
11801085
1181また、UNITCHECK ブロックのため値はないことに注意してくださ
1086リプト最初で、そスクリプトを実行しているインタプリタのバージョンが
1182ぜなら、これらはコンパイルユニット毎独立に実行され
1087適切範囲内あるかを調べるといたことができます:
1183グローバルなインタプリタフェーズではないからです。
11841088
1185=begin original
1089 warn "No PerlIO!\n" if "$]" < 5.008;
11861090
1187Not every program has to go through each of the possible phases, but
1188transition from one phase to another can only happen in the order
1189described in the above list.
1190
1191=end original
1192
1193全てのプログラムが可能な全てのフェーズを通らなければならないわけでは
1194ありませんが、あるフェーズから他のフェーズへの移行は上述の
1195順でのみ起こります。
1196
11971091=begin original
11981092
1199An example of all of the phases Perl code can see:
1093When comparing C<$]>, numeric comparison operators should be used, but the
1094variable should be stringified first to avoid issues where its original
1095numeric value is inaccurate.
12001096
12011097=end original
12021098
1203Perl コードの全てのフェーズです:
1099C<$]>比較すとき、数値比較演算子が使われるべきですが、
1100元の数値が不正確な場合の問題を避けるために、まず文字列化するべきです。
12041101
1205 BEGIN { print "compile-time: ${^GLOBAL_PHASE}\n" }
1206
1207 INIT { print "init-time: ${^GLOBAL_PHASE}\n" }
1208
1209 CHECK { print "check-time: ${^GLOBAL_PHASE}\n" }
1210
1211 {
1212 package Print::Phase;
1213
1214 sub new {
1215 my ($class, $time) = @_;
1216 return bless \$time, $class;
1217 }
1218
1219 sub DESTROY {
1220 my $self = shift;
1221 print "$$self: ${^GLOBAL_PHASE}\n";
1222 }
1223 }
1224
1225 print "run-time: ${^GLOBAL_PHASE}\n";
1226
1227 my $runtime = Print::Phase->new(
1228 "lexical variables are garbage collected before END"
1229 );
1230
1231 END { print "end-time: ${^GLOBAL_PHASE}\n" }
1232
1233 our $destruct = Print::Phase->new(
1234 "package variables are garbage collected after END"
1235 );
1236
12371102=begin original
12381103
1239This will print out
1104See also the documentation of L<C<use VERSION>|perlfunc/use VERSION> and
1105C<require VERSION> for a convenient way to fail if the running Perl
1106interpreter is too old.
12401107
12411108=end original
12421109
1243これは以下のものを出力しま:
1110実行る Perl インタプリタが古すぎる場合に終了する便利な方法に
1111ついては L<C<use VERSION>|perlfunc/use VERSION> と
1112C<require VERSION> のドキュメントも
1113参照して下さい。
12441114
1245 compile-time: START
1246 check-time: CHECK
1247 init-time: INIT
1248 run-time: RUN
1249 lexical variables are garbage collected before END: RUN
1250 end-time: END
1251 package variables are garbage collected after END: DESTRUCT
1252
12531115=begin original
12541116
1255This variable was added in Perl 5.14.0.
1117See L</$^V> for a representation of the Perl version as a L<version>
1118object, which allows more flexible string comparisons.
12561119
12571120=end original
12581121
1259この変数は Perl 5.14.0 で追加されまた。
1122より柔軟な文字列比較が可能な L<version> オブジェクトとての
1123Perl バージョン表現については L</$^V> を参照してください。
12601124
1261=item $^H
1262X<$^H>
1263
12641125=begin original
12651126
1266WARNING: This variable is strictly for internal use only. Its availability,
1127The main advantage of C<$]> over C<$^V> is that it works the same on any
1267behavior, and contents are subject to change without notice.
1128version of Perl. The disadvantages are that it can't easily be compared
1129to versions in other formats (e.g. literal v-strings, "v1.2.3" or
1130version objects) and numeric comparisons are subject to the binary
1131floating point representation; it's good for numeric literal version
1132checks and bad for comparing to a variable that hasn't been
1133sanity-checked.
12681134
12691135=end original
12701136
1271警告: 変数厳密内部使用に限定されます。
1137C<$^V> に対する C<$]> 主な利点、どのバージョンの Perl でも同様
1272その可用性、挙、内容は告知なく変更され可能性があります。
1138作すことです。
1139欠点は、他の型式のバージョン (例えばリテラルな v-文字列、"v1.2.3"、
1140バージョンオブジェクト) と簡単に比較できず、数値比較はバイナリ
1141浮動小数点表現になりがちです; 数値リテラルバージョンチェックとしては
1142良いですが、正気チェックをされていない変数と比較するには良くないです。
12731143
12741144=begin original
12751145
1276This variable contains compile-time hints for the Perl interpreter. At the
1146The C<$OLD_PERL_VERSION> form was added in Perl v5.20.0 for historical
1277end of compilation of a BLOCK the value of this variable is restored to the
1147reasons but its use is discouraged. (If your reason to use C<$]> is to
1278value when the interpreter started to compile the BLOCK.
1148run code on old perls then referring to it as C<$OLD_PERL_VERSION> would
1149be self-defeating.)
12791150
12801151=end original
12811152
1282この変数には Perl インタプリタのコンパイル時のヒントが入りす。
1153C<$OLD_PERL_VERSION> 型式歴史的理由により Perl v5.20.0 に追加されしたが、
1283BLOCK のコンパイル終了時に、この変数の値
1154この使用非推奨です。
1284インタプリタBLOCK ンパイル開始した時の値に戻されま
1155(C<$]> を使う理由古い perl ード実行ることなら、これを
1156C<$OLD_PERL_VERSION> して参照すると自滅することになります。)
12851157
12861158=begin original
12871159
1288When perl begins to parse any block construct that provides a lexical scope
1160Mnemonic: Is this version of perl in the right bracket?
1289(e.g., eval body, required file, subroutine body, loop body, or conditional
1290block), the existing value of C<$^H> is saved, but its value is left unchanged.
1291When the compilation of the block is completed, it regains the saved value.
1292Between the points where its value is saved and restored, code that
1293executes within BEGIN blocks is free to change the value of C<$^H>.
12941161
12951162=end original
12961163
1297Perl がレキシカルスコープを持つブロック構造(eval 中身、required された
1164記憶法: Perl のバージョンは正しい範囲 (right bracket) にあるか。
1298ファイル、サブルーチンの中身、loop の中身、条件付きブロック)の
1299パーズを開始するとき、現在の C<$^H> の値は保存されますが、値は
1300変更されません。
1301ブロックのコンパイルが終わると、保存された値が戻されます。
1302値の保存と回復の間の地点で、BEGIN ブロックの中で実行されるコードは自由に
1303C<$^H> の値を変更できます。
13041165
1305=begin original
1166=item $SYSTEM_FD_MAX
13061167
1307This behavior provides the semantic of lexical scoping, and is used in,
1168=item $^F
1308for instance, the C<use strict> pragma.
1169X<$^F> X<$SYSTEM_FD_MAX>
13091170
1310=end original
1311
1312この振る舞いはレキシカルスコープを持ち、その中で使えます。
1313例としては C<use strict> があります。
1314
13151171=begin original
13161172
1317The contents should be an integer; different bits of it are used for
1173The maximum system file descriptor, ordinarily 2. System file
1318different pragmatic flags. Here's an example:
1174descriptors are passed to C<exec()>ed processes, while higher file
1175descriptors are not. Also, during an
1176C<open()>, system file descriptors are
1177preserved even if the C<open()> fails (ordinary file descriptors are
1178closed before the C<open()> is attempted). The close-on-exec
1179status of a file descriptor will be decided according to the value of
1180C<$^F> when the corresponding file, pipe, or socket was opened, not the
1181time of the C<exec()>.
13191182
13201183=end original
13211184
1322内容は整数であべきです。
1185システムが使用すファイル記述子の最大値を示し、通常は 2 です。
1323ビット毎に異なるプラグマラグとして使われます。以下は例です:
1186システムァイル記述子は、C<exec()> さたプロセスに渡されますが、
1187それ以降のファイル記述子は渡されません。
1188また、C<open()> の実行中は、システムファイル記述子は、
1189たとえ C<open()> が失敗しても、保存されます
1190(通常のファイル記述子は、C<open()> が実行される前にクローズされます)。
1191ファイル記述子の close-on-exec のステータスは、C<exec()> 時ではなく、
1192対応するファイル、パイプソケットの open 時の C<$^F> の値によって
1193決められます。
13241194
1325 sub add_100 { $^H |= 0x100 }
1195=item @F
1196X<@F>
13261197
1327 sub foo {
1328 BEGIN { add_100() }
1329 bar->baz($boon);
1330 }
1331
13321198=begin original
13331199
1334Consider what happens during execution of the BEGIN block. At this point
1200The array C<@F> contains the fields of each line read in when autosplit
1335the BEGIN block has already been compiled, but the body of C<foo()> is still
1201mode is turned on. See L<perlrun|perlrun/-a> for the B<-a> switch. This
1336being compiled. The new value of C<$^H> will therefore be visible only while
1202array is package-specific, and must be declared or given a full package
1337the body of C<foo()> is being compiled.
1203name if not in package main when running under C<strict 'vars'>.
13381204
13391205=end original
13401206
1341BEGIN ブロック実行中起こることを考えてます。
1207自動 split モードが有効場合、配列 C<@F> は読込んだ行のフィールドを
1342この時点で BEGIN ブロックは既にコンパイルされていますが、
1208含みます
1343C<foo()> の中身コンパイル中です
1209B<-a> オプションについて L<perlrun|perlrun/-a> を参照してくさい
1344従って C<$^H> 新しい値は C<foo()> の中身がコンパイル中にのみ
1210配列パッケージ固有であり、もし C<strict 'vars'> で実行していて
1345見ることが出来ます。
1211パッケージ main 以外の場合は完全なパッケージ名で定義したり与えたり
1212しなければなりません。
13461213
1347=begin original
1348
1349Substitution of C<BEGIN { add_100() }> block with:
1350
1351=end original
1352
1353C<BEGIN { add_100() }> ブロックを以下のように変更すると:
1354
1355 BEGIN { require strict; strict->import('vars') }
1356
1357=begin original
1358
1359demonstrates how C<use strict 'vars'> is implemented. Here's a conditional
1360version of the same lexical pragma:
1361
1362=end original
1363
1364どのように C<use strict 'vars'> が実装されているかがわかります。
1365以下は同じレキシカルプラグマの条件付き版です:
1366
1367 BEGIN { require strict; strict->import('vars') if $condition }
1368
1369=begin original
1370
1371This variable was added in Perl 5.003.
1372
1373=end original
1374
1375この変数は Perl 5.003 で追加されました。
1376
1377=item %^H
1378X<%^H>
1379
1380=begin original
1381
1382The C<%^H> hash provides the same scoping semantic as C<$^H>. This makes it
1383useful for implementation of lexically scoped pragmas. See L<perlpragma>.
1384
1385=end original
1386
1387C<%^H> ハッシュは C<$^H> と同じスコープを持ちます。
1388これはレキシカルスコープを持つプラグマを実装するのに便利です。
1389L<perlpragma> を参照してください。
1390
1391=begin original
1392
1393This variable was added in Perl 5.6.
1394
1395=end original
1396
1397この変数は Perl 5.6 で追加されました。
1398
13991214=item @INC
14001215X<@INC>
14011216
14021217=begin original
14031218
14041219The array C<@INC> contains the list of places that the C<do EXPR>,
1405C<require>, or C<use> constructs look for their library files. It
1220C<require>, or C<use> constructs look for their library files. It
14061221initially consists of the arguments to any B<-I> command-line
14071222switches, followed by the default Perl library, probably
1408F</usr/local/lib/perl>, followed by ".", to represent the current
1223F</usr/local/lib/perl>.
1409directory. ("." will not be appended if taint checks are enabled,
1224Prior to Perl 5.26, C<.> -which represents the current directory, was included
1410either by C<-T> or by C<-t>.) If you need to modify this at runtime,
1225in C<@INC>; it has been removed. This change in behavior is documented
1411you should use the C<use lib> pragma to get the machine-dependent
1226in L<C<PERL_USE_UNSAFE_INC>|perlrun/PERL_USE_UNSAFE_INC> and it is
1412library properly loaded also:
1227not recommended that C<.> be re-added to C<@INC>.
1228If you need to modify C<@INC> at runtime, you should use the C<use lib> pragma
1229to get the machine-dependent library properly loaded as well:
14131230
14141231=end original
14151232
14161233配列 C<@INC> には、C<do EXPR>, C<require>, C<use> によってライブラリファイルを
14171234探すときに評価する場所のリストが納められています。
1418初期状態では、コマンドラインスイッチ B<-I> の引数と
1235初期状態では、コマンドラインスイッチ B<-I> の引数とデフォルトの
1419デフォルトの Perl ライブラリディレクトリ (おそらく
1236Perl ライブラリディレクトリ (おそらく F</usr/local/lib/perl5>) を
1420F</usr/local/lib/perl5>) とカレントディレクトリを表わ
1237順につなげたもので
1421"." を順につなげたものです
1238Perl 5.26 より前は、カレントディレクトリを表 C<.>
1422(C<-T> C<-t> によっ汚染チェックが有効の場合は、"."追加されません)
1239 C<@INC> に含まれいました; これ削除されました
1423実行時にれを変更する必要がある場合、マシン依存のライブラリも正しく
1240の振る舞いの変更は
1241L<C<PERL_USE_UNSAFE_INC>|perlrun/PERL_USE_UNSAFE_INC> に文書化されていて、
1242C<@INC> に C<.> を再追加するのは推奨されません。
1243実行時に C<@INC> 変更する必要がある場合は、マシン依存のライブラリも正しく
14241244読み込むために C<use lib> を使うべきです:
14251245
1426 use lib '/mypath/libdir/';
1246 use lib '/mypath/libdir/';
1427 use SomeMod;
1247 use SomeMod;
14281248
14291249=begin original
14301250
14311251You can also insert hooks into the file inclusion system by putting Perl
1432code directly into C<@INC>. Those hooks may be subroutine references, array
1252code directly into C<@INC>. Those hooks may be subroutine references,
1433references or blessed objects. See L<perlfunc/require> for details.
1253array references or blessed objects. See L<perlfunc/require> for details.
14341254
14351255=end original
14361256
14371257Perl のコードを直接 C<@INC> に入れることで、ファイルインクルード機構に
14381258フックを挿入できます。
14391259このフックはサブルーチンリファレンス、配列リファレンス、bless された
14401260オブジェクトが可能です。
14411261詳細については L<perlfunc/require> を参照してください。
14421262
14431263=item %INC
14441264X<%INC>
14451265
14461266=begin original
14471267
14481268The hash C<%INC> contains entries for each filename included via the
1449C<do>, C<require>, or C<use> operators. The key is the filename
1269C<do>, C<require>, or C<use> operators. The key is the filename
14501270you specified (with module names converted to pathnames), and the
1451value is the location of the file found. The C<require>
1271value is the location of the file found. The C<require>
14521272operator uses this hash to determine whether a particular file has
14531273already been included.
14541274
14551275=end original
14561276
14571277ハッシュ C<%INC> は、C<do>, C<require>, C<use> 演算子によって
14581278インクルードされた、個々のファイル名をエントリとして持っています。
14591279key は指定したファイル名(モジュール名はパス名に変換されます)で、
14601280value は見つかった場所となっています。
14611281C<require> 演算子は、指定されたファイル名が既に
14621282インクルードされているかを、このハッシュを使って調べます。
14631283
14641284=begin original
14651285
14661286If the file was loaded via a hook (e.g. a subroutine reference, see
14671287L<perlfunc/require> for a description of these hooks), this hook is
1468by default inserted into C<%INC> in place of a filename. Note, however,
1288by default inserted into C<%INC> in place of a filename. Note, however,
14691289that the hook may have set the C<%INC> entry by itself to provide some more
14701290specific info.
14711291
14721292=end original
14731293
14741294ファイルがフック(つまりサブルーチンリファレンス; フックに関する
14751295説明については L<perlfunc/require> を参照してください)経由で読み込まれた
14761296場合、このフックはデフォルトではファイル名の代わりに C<%INC> に挿入されます。
14771297しかし、フックはさらなる特定の情報を提供するために、自身で C<%INC> エントリを
14781298セットするかもしれないことに注意してください。
14791299
1300=item $INC
1301X<$INC>
1302
1303=begin original
1304
1305As of 5.37.7 when an C<@INC> hook is executed the index of the C<@INC>
1306array that holds the hook will be localized into the C<$INC> variable.
1307When the hook returns the integer successor of its value will be used to
1308determine the next index in C<@INC> that will be checked, thus if it is
1309set to -1 (or C<undef>) the traversal over the C<@INC> array will be
1310restarted from its beginning.
1311
1312=end original
1313
13145.37.7 から、C<@INC> フックが実行されるとき、フックを保持する
1315C<@INC> 配列のインデックスは C<$INC> 変数にローカル化されます。
1316フックが整数を返すとき、その値の継承はチェックされる C<@INC> の
1317次のインデックスを決定するために使われます;
1318従って、もしそれが -1 (または C<undef>)に設定されるなら、
1319C<@INC> 配列上の走査は最初から再開されます。
1320
1321=begin original
1322
1323Normally traversal through the C<@INC> array is from beginning to end
1324(C<0 .. $#INC>), and if the C<@INC> array is modified by the hook the
1325iterator may be left in a state where newly added entries are skipped.
1326Changing this value allows an C<@INC> hook to rewrite the C<@INC> array
1327and tell Perl where to continue afterwards. See L<perlfunc/require> for
1328details on C<@INC> hooks.
1329
1330=end original
1331
1332通常、C<@INC> 配列のトラバースは最初から最後まで
1333(C<0 .. $#INC>) であり、C<@INC> 配列がフックによって変更された場合、
1334反復子は新しく追加されたエントリが読み飛ばされる状態のままになる
1335可能性があります。
1336この値を変更すると、C<@INC> フックが C<@INC> 配列を書き換え、
1337後でどこに進むかを Perl に指示できます。
1338C<@INC> フックの詳細については L<perlfunc/require> を参照してください。
1339
14801340=item $INPLACE_EDIT
14811341
14821342=item $^I
14831343X<$^I> X<$INPLACE_EDIT>
14841344
14851345=begin original
14861346
1487The current value of the inplace-edit extension. Use C<undef> to disable
1347The current value of the inplace-edit extension. Use C<undef> to disable
14881348inplace editing.
14891349
14901350=end original
14911351
14921352置き換え編集の拡張子の値を示します。
14931353置き換え編集を禁止するためには、C<undef> を設定します。
14941354
14951355=begin original
14961356
14971357Mnemonic: value of B<-i> switch.
14981358
14991359=end original
15001360
15011361記憶法: B<-i> スイッチの値。
15021362
1363=item @ISA
1364X<@ISA>
1365
1366=begin original
1367
1368Each package contains a special array called C<@ISA> which contains a list
1369of that class's parent classes, if any. This array is simply a list of
1370scalars, each of which is a string that corresponds to a package name. The
1371array is examined when Perl does method resolution, which is covered in
1372L<perlobj>.
1373
1374=end original
1375
1376それぞれのパッケージには C<@ISA> という名前の特殊配列があります;
1377これは (もしあれば) そのクラスの親クラスのリストです。
1378この変数は単なるスカラのリストで、それぞれはパッケージ名に対応する
1379文字列です。
1380この配列は Perl がメソッド解決を行うときにチェックされます; これは
1381L<perlobj> に記述しています。
1382
1383=begin original
1384
1385To load packages while adding them to C<@ISA>, see the L<parent> pragma. The
1386discouraged L<base> pragma does this as well, but should not be used except
1387when compatibility with the discouraged L<fields> pragma is required.
1388
1389=end original
1390
1391パッケージを読み込むために C<@ISA> に追加するには、L<parent> プラグマを
1392参照してください。
1393非推奨の L<base> プラグマは同じことをしますが、
1394非推奨の L<fields> プラグマとの互換性が必要な場合を除いて、
1395使うべきではありません。
1396
15031397=item $^M
15041398X<$^M>
15051399
15061400=begin original
15071401
15081402By default, running out of memory is an untrappable, fatal error.
15091403However, if suitably built, Perl can use the contents of C<$^M>
1510as an emergency memory pool after C<die()>ing. Suppose that your Perl
1404as an emergency memory pool after C<die()>ing. Suppose that your Perl
15111405were compiled with C<-DPERL_EMERGENCY_SBRK> and used Perl's malloc.
15121406Then
15131407
15141408=end original
15151409
15161410デフォルトでは、メモリ不足はトラップできない致命的エラーとなります。
15171411しかし、もし適切に構築されていれば、Perl は C<$^M> の中身を
15181412C<die()> した後の緊急用メモリとして使えます。
15191413Perl が C<-DPERL_EMERGENCY_SBRK> 付きでコンパイルされ、
15201414Perl の malloc を使うと仮定します。そして、
15211415
1522 $^M = 'a' x (1 << 16);
1416 $^M = 'a' x (1 << 16);
15231417
15241418=begin original
15251419
1526would allocate a 64K buffer for use in an emergency. See the
1420would allocate a 64K buffer for use in an emergency. See the
1527F<INSTALL> file in the Perl distribution for information on how to
1421L<INSTALL> file in the Perl distribution for information on how to
1528add custom C compilation flags when compiling perl. To discourage casual
1422add custom C compilation flags when compiling perl. To discourage casual
15291423use of this advanced feature, there is no L<English|English> long name for
15301424this variable.
15311425
15321426=end original
15331427
15341428とすると緊急用の 64K のバッファを割り当てます。
15351429perl をコンパイルするときに独自の C コンパイルフラグを追加する
15361430方法についての情報は、Perl 配布パッケージに含まれている
1537F<INSTALL> ファイルを参照して下さい。
1431L<INSTALL> ファイルを参照して下さい。
15381432この拡張機能を気軽に使えないようにするために、
15391433この変数には L<English|English> の長い名前はありません。
15401434
15411435=begin original
15421436
15431437This variable was added in Perl 5.004.
15441438
15451439=end original
15461440
15471441この変数は Perl 5.004 で追加されました。
15481442
1549=item $OSNAME
1443=item ${^MAX_NESTED_EVAL_BEGIN_BLOCKS}
15501444
1551=item $^O
1552X<$^O> X<$OSNAME>
1553
15541445=begin original
15551446
1556The name of the operating system under which this copy of Perl was
1447This variable determines the maximum number C<eval EXPR>/C<BEGIN> or
1557built, as determined during the configuration process. For examples
1448C<require>/C<BEGIN> block nesting that is allowed. This means it also
1558see L<perlport/PLATFORMS>.
1449controls the maximum nesting of C<use> statements as well.
15591450
15601451=end original
15611452
1562この Perl が構築されたオペレーティングシステムの名前です。
1453この変数は、C<eval EXPR>/C<BEGIN> や C<require>/C<BEGIN>
1563これは設定プ中に決定されます。
1454ックのネトの許される最大数を決定します。
1455つまり、C<use> 文のネストの最大数も制御します。
15641456
15651457=begin original
15661458
1567The value is identical to C<$Config{'osname'}>. See also L<Config>
1459The default of 1000 should be sufficiently large for normal working
1568and the B<-V> command-line switch documented in L<perlrun>.
1460purposes, and if you must raise it then you should be conservative
1461with your choice or you may encounter segfaults from exhaustion of
1462the C stack. It seems unlikely that real code has a use depth above
14631000, but we have left this configurable just in case.
15691464
15701465=end original
15711466
1572値は C<$Config{'osname'}> と同じです
1467デフォルト1000 は、通常の作業目的に十分な大きさあるはずで;
1573L<Config> とL<perlrun> で文書化されてい
1468値を大きくする必要がある場合は慎重に選択す必要があります;
1574B<-V> コマンドラインチも参照し下さい
1469そうしないと、Cクの枯渇によっ segfault が発生する可能性があります
1470実際のコードが 1000 を超える使用深度を持つ可能性は低いと思われますが、
1471念のためこれを設定できるようにしてあります。
15751472
15761473=begin original
15771474
1578In Windows platforms, C<$^O> is not very helpful: since it is always
1475When set to C<0> then C<BEGIN> blocks inside of C<eval EXPR> or
1579C<MSWin32>, it doesn't tell the difference between
1476C<require EXPR> are forbidden entirely and will trigger an exception
158095/98/ME/NT/2000/XP/CE/.NET. Use C<Win32::GetOSName()> or
1477which will terminate the compilation and in the case of C<require>
1581Win32::GetOSVersion() (see L<Win32> and L<perlport>) to distinguish
1478will throw an exception, or in the case of C<eval> return the error in
1582between the variants.
1479C<$@> as usual.
15831480
15841481=end original
15851482
1586Windows プラットフォームでは、C<$^O> はあまり役に立ちません: これは常に
1483C<0> に設定すると、C<eval EXPR> C<require EXPR> 内の
1587C<MSWin32> となり、95/98/ME/NT/2000/XP/CE/.NET の違い示していないからで
1484C<BEGIN> ブロックは完全に禁止され、コンパイル終了
1588これら区別るためには、C<Win32::GetOSName()> や Win32::GetOSVersion() を
1485例外引き起こしま;
1589使ってください (L<Win32> と L<perlport> を参照してください)。
1486C<require> の場合は例外を投げ、C<eval> の場合は通常どおり
1487C<$@> にエラーを返します。
15901488
15911489=begin original
15921490
1593This variable was added in Perl 5.003.
1491Consider the code
15941492
15951493=end original
15961494
1597変数は Perl 5.003 で追加されした。
1495コードを考えす:
15981496
1599=item ${^OPEN}
1497 perl -le'sub f { eval "BEGIN { f() }"; } f()'
1600X<${^OPEN}>
16011498
16021499=begin original
16031500
1604An internal variable used by PerlIO. A string in two parts, separated
1501each invocation of C<f()> will consume considerable C stack, and this
1605by a C<\0> byte, the first part describes the input layers, the second
1502variable is used to cause code like this to die instead of exhausting
1606part describes the output layers.
1503the C stack and triggering a segfault. Needless to say code like this is
1504unusual, it is unlikely you will actually need to raise the setting.
1505However it may be useful to set it to 0 for a limited time period to
1506prevent BEGIN{} blocks from being executed during an C<eval EXPR>.
16071507
16081508=end original
16091509
1610PerlIO で使われる内部変数です。
1510C<f()> の各呼び出しはかなりの C スタックを消費し、この変数は、
1611文字列は C<\0> で分割され二つの部分からなり、前半は入力層
1511このようなコードが C スタックを使い果して segfault
1612後半出力層を示します。
1512引き起こすのでなく、die させるために使われます。
1513このようなコードが普通ではないことは言うまでもありませんが、実際に
1514設定を上げる必要があることはあまりありません。
1515ただし、C<eval EXPR> 中に BEGIN{} ブロックが実行されないようにするために、
1516限られた時間だけ 0 に設定すると便利な場合があります。
16131517
16141518=begin original
16151519
1616This variable was added in Perl 5.8.2.
1520Note that setting this to 1 would NOT affect code like this:
16171521
16181522=end original
16191523
1620この変数は Perl 5.8.2 で追加されまた。
15241 への設定は、次のようなコードには影響ません:
16211525
1622=item $PERLDB
1526 BEGIN { $n += 1; BEGIN { $n += 2; BEGIN { $n += 4 } } }
16231527
1624=item $^P
1625X<$^P> X<$PERLDB>
1626
16271528=begin original
16281529
1629The internal variable for debugging support. The meanings of the
1530The reason is that BEGIN blocks are executed immediately after they are
1630various bits are subject to change, but currently indicate:
1531completed, thus the innermost will execute before the ones which contain
1532it have even finished compiling, and the depth will not go above 1. In
1533fact the above code is equivalent to
16311534
16321535=end original
16331536
1634デバッグ機能のための内部変数です
1537理由は、BEGIN ブロックは完了し直後に実行されるためです;
1635それぞれトの意味変わるかもしません
1538したがって、最も内側ブロ、そを含むブロックコンパイルを
1636現在のところは以下の通りで:
1539完了る前に実行され、深さは 1 を超えません。
1540実際、前述のコードは次と等価です:
16371541
1638=over 6
1542 BEGIN { $n+=4 }
1543 BEGIN { $n+=2 }
1544 BEGIN { $n+=1 }
16391545
1640=item 0x01
1641
16421546=begin original
16431547
1644Debug subroutine enter/exit.
1548which makes it obvious why a ${^MAX_EVAL_BEGIN_DEPTH} of 1 would not
1549block this code.
16451550
16461551=end original
16471552
1648サブルーチンの出入りデバッグしま
1553これは、なぜ ${^MAX_EVAL_BEGIN_DEPTH} 1 にることが
1554このコードをブロックしないかを分かりやすくします。
16491555
1650=item 0x02
1651
16521556=begin original
16531557
1654Line-by-line debugging. Causes C<DB::DB()> subroutine to be called for each
1558Only C<BEGIN>'s executed inside of an C<eval> or C<require> (possibly via
1655statement executed. Also causes saving source code lines (like 0x400).
1559C<use>) are affected.
16561560
16571561=end original
16581562
1659行毎にデバッグしす。
1563C<eval> たは (C<use> 経由を含む) C<require> の内側で実行された
1660各行を実行する毎に C<DB::DB()> サブルーチン呼び出します。
1564C<BEGIN> のみが影響受けます。
1661さらに、(0x400 のように) ソースコードを保存します。
16621565
1663=item 0x04
1566=item $OSNAME
16641567
1665=begin original
1568=item $^O
1569X<$^O> X<$OSNAME>
16661570
1667Switch off optimizations.
1668
1669=end original
1670
1671最適化を行いません。
1672
1673=item 0x08
1674
16751571=begin original
16761572
1677Preserve more data for future interactive inspections.
1573The name of the operating system under which this copy of Perl was
1574built, as determined during the configuration process. For examples
1575see L<perlport/PLATFORMS>.
16781576
16791577=end original
16801578
1681将来対話的な検査のめにより多くのデタを保存しま
1579 Perl が構築されオペレティングシステムの名前で;
1580これは設定プロセス中に決定されます。
1581例えば L<perlport/PLATFORMS> を参照してください。
16821582
1683=item 0x10
1684
16851583=begin original
16861584
1687Keep info about source lines on which a subroutine is defined.
1585The value is identical to C<$Config{'osname'}>. See also L<Config>
1586and the B<-V> command-line switch documented in L<perlrun|perlrun/-V>.
16881587
16891588=end original
16901589
1691サブルーチンが定義されたソース行に関する情報を保持します。
1590この値は C<$Config{'osname'}> と同じです。
1591L<Config> と、L<perlrun|perlrun/-V> で文書化されている
1592B<-V> コマンドラインスイッチも参照して下さい。
16921593
1693=item 0x20
1694
16951594=begin original
16961595
1697Start with single-step on.
1596In Windows platforms, C<$^O> is not very helpful: since it is always
1597C<MSWin32>, it doesn't tell the difference between
159895/98/ME/NT/2000/XP/CE/.NET. Use C<Win32::GetOSName()> or
1599Win32::GetOSVersion() (see L<Win32> and L<perlport>) to distinguish
1600between the variants.
16981601
16991602=end original
17001603
1701シングルステッ実行開始しす。
1604Windows ラットフォームは、C<$^O> はあり役に立ちません: これは常に
1605C<MSWin32> となり、95/98/ME/NT/2000/XP/CE/.NET の違いを示していないからです。
1606これらを区別するためには、C<Win32::GetOSName()> や Win32::GetOSVersion() を
1607使ってください (L<Win32> と L<perlport> を参照してください)。
17021608
1703=item 0x40
1704
17051609=begin original
17061610
1707Use subroutine address instead of name when reporting.
1611This variable was added in Perl 5.003.
17081612
17091613=end original
17101614
1711報告時にサブルーチン名でなくサブルーチンアドレスを使い
1615変数は Perl 5.003 で追加されした
17121616
1713=item 0x80
1617=item %SIG
1618X<%SIG>
17141619
17151620=begin original
17161621
1717Report C<goto &subroutine> as well.
1622The hash C<%SIG> contains signal handlers for signals. For example:
17181623
17191624=end original
17201625
1721C<goto &subroutine> も同様報告します。
1626ハッシュ C<%SIG> にはシグナルのためのシグナルハンドラが含まれています。
1627例えば:
17221628
1723=item 0x100
1724
17251629=begin original
17261630
1727Provide informative "file" names for evals based on the place they were compiled.
1631 sub handler { # 1st argument is signal name
1632 my($sig) = @_;
1633 print "Caught a SIG$sig--shutting down\n";
1634 close(LOG);
1635 exit(0);
1636 }
17281637
17291638=end original
17301639
1731eval に対して、コンパイされた位置を元にした「ファイル」を提供します。
1640 sub handler { # 最初の引数はシグナル名
1641 my($sig) = @_;
1642 print "Caught a SIG$sig--shutting down\n";
1643 close(LOG);
1644 exit(0);
1645 }
17321646
1733=item 0x200
1734
17351647=begin original
17361648
1737Provide informative names to anonymous subroutines based on the place they
1649 $SIG{'INT'} = \&handler;
1738were compiled.
1650 $SIG{'QUIT'} = \&handler;
1651 ...
1652 $SIG{'INT'} = 'DEFAULT'; # restore default action
1653 $SIG{'QUIT'} = 'IGNORE'; # ignore SIGQUIT
17391654
17401655=end original
17411656
1742無名サブルーチンに対して、
1657 $SIG{'INT'} = \&handler;
1743コンパイルされた位置を基にした参考名を提供します。
1658 $SIG{'QUIT'} = \&handler;
1659 ...
1660 $SIG{'INT'} = 'DEFAULT'; # デフォルトの動作を復元
1661 $SIG{'QUIT'} = 'IGNORE'; # SIGQUIT を無視
17441662
1745=item 0x400
1746
17471663=begin original
17481664
1749Save source code lines into C<@{"_<$filename"}>.
1750
1751=end original
1752
1753ソースコードの行数を C<@{"_<$filename"}> に保存します。
1754
1755=back
1756
1757=begin original
1758
1759Some bits may be relevant at compile-time only, some at
1760run-time only. This is a new mechanism and the details may change.
1761See also L<perldebguts>.
1762
1763=end original
1764
1765無名サブルーチンに対して、
1766コンパイルされた位置を基にした参考名を提供します。
1767L<perldebguts> も参照してください。
1768
1769=item %SIG
1770X<%SIG>
1771
1772=begin original
1773
1774The hash C<%SIG> contains signal handlers for signals. For example:
1775
1776=end original
1777
1778ハッシュ C<%SIG> にはシグナルのためのシグナルハンドラが含まれています。
1779例えば:
1780
1781 sub handler { # 1st argument is signal name
1782 my($sig) = @_;
1783 print "Caught a SIG$sig--shutting down\n";
1784 close(LOG);
1785 exit(0);
1786 }
1787
1788 $SIG{'INT'} = \&handler;
1789 $SIG{'QUIT'} = \&handler;
1790 ...
1791 $SIG{'INT'} = 'DEFAULT'; # restore default action
1792 $SIG{'QUIT'} = 'IGNORE'; # ignore SIGQUIT
1793
1794=begin original
1795
17961665Using a value of C<'IGNORE'> usually has the effect of ignoring the
1797signal, except for the C<CHLD> signal. See L<perlipc> for more about
1666signal, except for the C<CHLD> signal. See L<perlipc> for more about
1798this special case.
1667this special case. Using an empty string or C<undef> as the value has
1668the same effect as C<'DEFAULT'>.
17991669
18001670=end original
18011671
18021672C<'IGNORE'> という値は通常はシグナルの効果を無視するために使いますが、
18031673C<CHLD> シグナルは例外です。
18041674この特別な場合に関する詳細は L<perlipc> を参照して下さい。
1675値として空文字列や C<undef> を使うのは C<'DEFAULT'> と同じ効果です。
18051676
18061677=begin original
18071678
18081679Here are some other examples:
18091680
18101681=end original
18111682
18121683以下にその他の例を示します:
18131684
18141685=begin original
18151686
1816 $SIG{"PIPE"} = "Plumber"; # assumes main::Plumber (not recommended)
1687 $SIG{"PIPE"} = "Plumber"; # assumes main::Plumber (not
1817 $SIG{"PIPE"} = \&Plumber; # just fine; assume current Plumber
1688 # recommended)
1818 $SIG{"PIPE"} = *Plumber; # somewhat esoteric
1689 $SIG{"PIPE"} = \&Plumber; # just fine; assume current
1819 $SIG{"PIPE"} = Plumber(); # oops, what did Plumber() return??
1690 # Plumber
1691 $SIG{"PIPE"} = *Plumber; # somewhat esoteric
1692 $SIG{"PIPE"} = Plumber(); # oops, what did Plumber()
1693 # return??
18201694
18211695=end original
18221696
18231697 $SIG{"PIPE"} = "Plumber"; # main::Plumber を仮定します(非推奨)
18241698 $SIG{"PIPE"} = \&Plumber; # 問題なし; カレントの Plumber を仮定します
18251699 $SIG{"PIPE"} = *Plumber; # 少々難解
18261700 $SIG{"PIPE"} = Plumber(); # げげ、Plumber() は何を返すの??
18271701
18281702=begin original
18291703
18301704Be sure not to use a bareword as the name of a signal handler,
18311705lest you inadvertently call it.
18321706
18331707=end original
18341708
1835裸の単語をシグナルハンドラの名前として使わないようにしてください
1709裸の単語をシグナルハンドラの名前として使わないようにしてください;
18361710不注意で呼び出すのを避けるためです。
18371711
18381712=begin original
18391713
1714Using a string that doesn't correspond to any existing function or a
1715glob that doesn't contain a code slot is equivalent to C<'IGNORE'>,
1716but a warning is emitted when the handler is being called (the warning
1717is not emitted for the internal hooks described below).
1718
1719=end original
1720
1721既存の関数に対応しない文字列や、コードスロットを含んでいないグロブを
1722使うのは、C<'IGNORE'> と等価ですが、ハンドラが呼び出されると警告が
1723発生します(後述する内部フックでは警告は発生しません)。
1724
1725=begin original
1726
18401727If your system has the C<sigaction()> function then signal handlers
1841are installed using it. This means you get reliable signal handling.
1728are installed using it. This means you get reliable signal handling.
18421729
18431730=end original
18441731
1845システムに sigaction() 関数がある場合は、シグナルハンドラ
1732システムに sigaction() 関数がある場合は、シグナルハンドラはそれを使って
1846インストールされ使われした
1733インストールされま
18471734これにより、信頼性のあるシグナルハンドリングが可能になります。
18481735
18491736=begin original
18501737
1851The default delivery policy of signals changed in Perl 5.8.0 from
1738The default delivery policy of signals changed in Perl v5.8.0 from
1852immediate (also known as "unsafe") to deferred, also known as
1739immediate (also known as "unsafe") to deferred, also known as "safe
1853"safe signals". See L<perlipc> for more information.
1740signals". See L<perlipc> for more information.
18541741
18551742=end original
18561743
1857デフォルトのシグナル配送ポリシーは Perl 5.8.0 に即時("unsafe"としても
1744デフォルトのシグナル配送ポリシーは Perl v5.8.0 に即時("unsafe"としても
18581745知られます)から保留(「安全なシグナル」としても知られます)に変更されました。
18591746さらなる情報については L<perlipc> を参照してください。
18601747
18611748=begin original
18621749
1863Certain internal hooks can be also set using the C<%SIG> hash. The
1750Certain internal hooks can be also set using the C<%SIG> hash. The
18641751routine indicated by C<$SIG{__WARN__}> is called when a warning
1865message is about to be printed. The warning message is passed as the
1752message is about to be printed. The warning message is passed as the
1866first argument. The presence of a C<__WARN__> hook causes the
1753first argument. The presence of a C<__WARN__> hook causes the
1867ordinary printing of warnings to C<STDERR> to be suppressed. You can
1754ordinary printing of warnings to C<STDERR> to be suppressed. You can
18681755use this to save warnings in a variable, or turn warnings into fatal
18691756errors, like this:
18701757
18711758=end original
18721759
18731760ある種の内部フックも %SIG ハッシュを使ってセットされます。
18741761警告メッセージを表示しようとするときに C<$SIG{__WARN__}> で
18751762示されたルーチンが呼び出されます。
18761763警告メッセージは最初の引数として渡されます。
18771764C<__WARN__> フックがあると、通常の C<STDERR> への警告の出力は行われません。
18781765これを使って、警告メッセージを変数にいれたり、
18791766あるいは以下のようにして警告を致命的エラーに変えたり出来ます:
18801767
1881 local $SIG{__WARN__} = sub { die $_[0] };
1768 local $SIG{__WARN__} = sub { die $_[0] };
1882 eval $proggie;
1769 eval $proggie;
18831770
18841771=begin original
18851772
1886As the C<'IGNORE'> hook is not supported by C<__WARN__>, you can
1773As the C<'IGNORE'> hook is not supported by C<__WARN__>, its effect is
1887disable warnings using the empty subroutine:
1774the same as using C<'DEFAULT'>. You can disable warnings using the
1775empty subroutine:
18881776
18891777=end original
18901778
1891C<__WARN__> では C<'IGNORE'> フックには対応していないので、空サブルーチンを
1779C<__WARN__> では C<'IGNORE'> フックには対応していないので、
1892使って警告を無に出来ま:
1780この果は C<'DEFAULT'> を使うのと同じで
1781空サブルーチンを使って警告を無効に出来ます:
18931782
1894 local $SIG{__WARN__} = sub {};
1783 local $SIG{__WARN__} = sub {};
18951784
18961785=begin original
18971786
18981787The routine indicated by C<$SIG{__DIE__}> is called when a fatal
1899exception is about to be thrown. The error message is passed as the
1788exception is about to be thrown. The error message is passed as the
1900first argument. When a C<__DIE__> hook routine returns, the exception
1789first argument. When a C<__DIE__> hook routine returns, the exception
19011790processing continues as it would have in the absence of the hook,
1902unless the hook routine itself exits via a C<goto>, a loop exit, or a
1791unless the hook routine itself exits via a C<goto &sub>, a loop exit,
1903C<die()>. The C<__DIE__> handler is explicitly disabled during the
1792or a C<die()>. The C<__DIE__> handler is explicitly disabled during
1904call, so that you can die from a C<__DIE__> handler. Similarly for
1793the call, so that you can die from a C<__DIE__> handler. Similarly
1905C<__WARN__>.
1794for C<__WARN__>.
19061795
19071796=end original
19081797
19091798C<$SIG{__DIE__}> で示されるルーチンは
19101799致命的な例外がまさに投げられようとするときに呼び出されます。
19111800エラーメッセージは最初の引数として渡されます。
1912C<__DIE__> フックから戻ると、
1801C<__DIE__> フックから戻ると、例外処理はフックがなかったかのように
1913例外処理はフックがなかったかのように再開されますが、
1802再開されますが、フックルーチン自体が C<goto &sub>、ループ終了
1914フックルーチン自体が C<goto>、ループ終了、C<die()> によって
1803C<die()> によって終了した場合を除きます。
1915終了した場合を除きます。
19161804C<__DIE__> ハンドラは呼び出し中は明示的に無効になりますので、
19171805C<__DIE__> ハンドラから die できます。
19181806C<__WARN__> も同様です。
19191807
19201808=begin original
19211809
1922Due to an implementation glitch, the C<$SIG{__DIE__}> hook is called
1810The C<$SIG{__DIE__}> hook is called even inside an C<eval()>. It was
1923even inside an C<eval()>. Do not use this to rewrite a pending
1811never intended to happen this way, but an implementation glitch made
1924exception in C<$@>, or as a bizarre substitute for overriding
1812this possible. This used to be deprecated, as it allowed strange action
1925C<CORE::GLOBAL::die()>. This strange action at a distance may be fixed
1813at a distance like rewriting a pending exception in C<$@>. Plans to
1926in a future release so that C<$SIG{__DIE__}> is only called if your
1814rectify this have been scrapped, as users found that rewriting a
1927program is about to exit, as was the original intent. Any other use is
1815pending exception is actually a useful feature, and not a bug.
1928deprecated.
19291816
19301817=end original
19311818
1932実装上の不具合により、C<$SIG{__DIE__}> は eval() の中でも
1819C<$SIG{__DIE__}> は eval() の中でも呼び出されます。
1933呼び出されます。これを、C<$@> の待っ例外書き換えたり、
1820これは決しこのようになこと意図しものではあませんでしたが
1934C<CORE::GLOBAL::die()> を書きするのに使わないでください
1821実装上のミスでこれが可能になってました
1935の奇妙な行動将来のリリース修正される予定なので、
1822以前廃止予定した; C<$@> で保留されてい例外を書き換えるといった
1936C<$SIG{__DIE__}> は当初の目的通り、
1823変わった行動を離れた場所でできるようにしていたからです。
1937プログラムが終了するときにのみ呼び出されるようになりす。
1824これを修正する計画は破棄されました;
1938他の用途非推奨す。
1825保留されている例外を書き換えるというのは実際有用な機能あることがわかり、
1826またバグではないからです。
19391827
19401828=begin original
19411829
1830The C<$SIG{__DIE__}> doesn't support C<'IGNORE'>; it has the same
1831effect as C<'DEFAULT'>.
1832
1833=end original
1834
1835C<$SIG{__DIE__}> は C<'IGNORE'> に対応していません;
1836これは C<'DEFAULT'> と同じ効果です。
1837
1838=begin original
1839
19421840C<__DIE__>/C<__WARN__> handlers are very special in one respect: they
1943may be called to report (probable) errors found by the parser. In such
1841may be called to report (probable) errors found by the parser. In such
19441842a case the parser may be in inconsistent state, so any attempt to
19451843evaluate Perl code from such a handler will probably result in a
1946segfault. This means that warnings or errors that result from parsing
1844segfault. This means that warnings or errors that result from parsing
19471845Perl should be used with extreme caution, like this:
19481846
19491847=end original
19501848
1951C<__DIE__> と C<__WARN__> のハンドラは一つの点で非常に特別です
1849C<__DIE__> と C<__WARN__> のハンドラは一つの点で非常に特別です:
1952パーによってエラー(であろうもの)を報告するために呼び出されることがある
1850パーによってエラー(であろうもの)を報告するために呼び出されることがある
19531851ことです。
1954このような場合、パーは不安定な状態になっているかもしれないので、
1852このような場合、パーは不安定な状態になっているかもしれないので、
19551853ハンドラから Perl コードを評価しようとするとセグメンテーションフォールトが
19561854発生するかもしれません。
1957Perl のパー中の警告やエラーは、以下のように非常に注意して扱うべきです;
1855Perl のパー中の警告やエラーは、以下のように非常に注意して扱うべきです;
19581856
1959 require Carp if defined $^S;
1857 require Carp if defined $^S;
1960 Carp::confess("Something wrong") if defined &Carp::confess;
1858 Carp::confess("Something wrong") if defined &Carp::confess;
1961 die "Something wrong, but could not load Carp to give backtrace...
1859 die "Something wrong, but could not load Carp to give "
1962 To see backtrace try starting Perl with -MCarp switch";
1860 . "backtrace...\n\t"
1861 . "To see backtrace try starting Perl with -MCarp switch";
19631862
19641863=begin original
19651864
1966
19671865Here the first line will load C<Carp> I<unless> it is the parser who
1968called the handler. The second line will print backtrace and die if
1866called the handler. The second line will print backtrace and die if
1969C<Carp> was available. The third line will be executed only if C<Carp> was
1867C<Carp> was available. The third line will be executed only if C<Carp> was
19701868not available.
19711869
19721870=end original
19731871
1974一行目は、I<パーが C<ハンドラ> を呼び出したのでなければ>
1872一行目は、パーが C<ハンドラ> を I<呼び出したのでなければ> C<Carp> を
1975Carp を読み込みます。
1873読み込みます。
1976C<二行目> は、Carp が使えるならバックとレースを表示して die します。
1874C<二行目> は、C<Carp> が使えるならバックとレースを表示して die します。
1977三行目は Carp が使えないときにのみ実行されます。
1875三行目は C<Carp> が使えないときにのみ実行されます。
19781876
19791877=begin original
19801878
19811879Having to even think about the C<$^S> variable in your exception
1982handlers is simply wrong. C<$SIG{__DIE__}> as currently implemented
1880handlers is simply wrong. C<$SIG{__DIE__}> as currently implemented
1983invites grievous and difficult to track down errors. Avoid it
1881invites grievous and difficult to track down errors. Avoid it
19841882and use an C<END{}> or CORE::GLOBAL::die override instead.
19851883
19861884=end original
19871885
19881886例外ハンドラの中で C<$^S> を使おうなどとは考えてもいけません。
19891887現在の実装の C<$SIG{__DIE__}> は面倒を引き寄せ、エラーの追跡を困難にします。
1990これの代わりに C<END{}> を使うか、CORE::GLOBAL::die をオーバーライドしてください。
1888これの代わりに C<END{}> を使うか、CORE::GLOBAL::die を
1889オーバーライドしてください。
19911890
19921891=begin original
19931892
19941893See L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>, and
19951894L<warnings> for additional information.
19961895
19971896=end original
19981897
19991898追加の情報については L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>,
20001899L<warnings> を参照して下さい。
20011900
2002=item $BASETIME
1901=item %{^HOOK}
1902X<%{^HOOK}>
20031903
2004=item $^T
2005X<$^T> X<$BASETIME>
2006
20071904=begin original
20081905
2009The time at which the program began running, in seconds since the
1906This hash contains coderefs which are called when various perl keywords
2010epoch (beginning of 1970). The values returned by the B<-M>, B<-A>,
1907which are hard or impossible to wrap are called. The keys of this hash
2011and B<-C> filetests are based on this value.
1908are named after the keyword that is being hooked, followed by two
1909underbars and then a phase term; either "before" or "after".
20121910
20131911=end original
20141912
2015プログムを実行開始し時刻を、紀元 (1970年の始め) からの秒数で示したものです。
1913このハッシュには、ップが困難まは不可能なさまざまな
2016ファイルテスト B<-M>、B<-A>、B<-C> で返される値は、この値基づいています。
1914perl キーワードが呼び出されたとき呼び出される
1915コードリファレンスが含まれています。
1916このハッシュのキーは、フックされているキーワードにちなんで
1917名前が付けられ、その後に二つのアンダーバーとフェーズ用語
1918("before" または "after")が続きます。
20171919
2018=item ${^TAINT}
2019X<${^TAINT}>
2020
20211920=begin original
20221921
2023Reflects if taint mode is on or off. 1 for on (the program was run with
1922Perl will throw an error if you attempt modify a key which is not
2024B<-T>), 0 for off, -1 when only taint warnings are enabled (i.e. with
1923documented to exist, or if you attempt to store anything other than a
2025B<-t> or B<-TU>).
1924code reference or undef in the hash. If you wish to use an object to
1925implement a hook you can use currying to embed the object into an
1926anonymous code reference.
20261927
20271928=end original
20281929
2029汚染検査モドのオン・オフ反映ます。
1930存在することが文書化されていないキーを変更ようとしたり、
20301 はオ(プログラムは B<-T> 付きで実行されている)、0 はオフ、-1 は汚染
1931コードリファレスや undef 以外のものをハッシュに
2031警告のみが有効になっている(つま B<-t> か B<-TU>)ことを意味します。
1932保存しようとしたする、Perl はエラー投げます。
1933フックを実装するためにオブジェクトを使用したい場合は、カリー化を
1934使って、オブジェクトに匿名コードリファレンスを埋め込むことができます。
20321935
20331936=begin original
20341937
2035This variable is read-only.
1938Currently there is only one keyword which can be hooked, C<require>, but
1939it is expected that in future releases there will be additional keywords
1940with hook support.
20361941
20371942=end original
20381943
2039この変数込み専用です
1944現在、フック可能なキーワード C<require> のみですが、将来のリリースでは
1945フックに対応するキーワードが追加される予定です。
20401946
1947=over 4
1948
1949=item require__before
1950
20411951=begin original
20421952
2043This variable was added in Perl 5.8.
1953The routine indicated by C<${^HOOK}{require__before}> is called by
1954C<require> B<before> it checks C<%INC>, looks up C<@INC>, calls INC
1955hooks, or compiles any code. It is called with a single argument, the
1956filename for the item being required (package names are converted to
1957paths). It may alter this filename to change what file is loaded. If
1958the hook dies during execution then it will block the require from executing.
20441959
20451960=end original
20461961
2047この変数は Perl 5.8 追加されました。
1962C<${^HOOK}{require__before}>されるルーチンは、
1963C<%INC> をチェックしたり、C<@INC> を検索したり、
1964INC フックを呼び出したり、任意のコードをコンパイルしたりする
1965B<前> に C<require> によって呼び出されます。
1966このルーチンは単一の引数で呼び出されます;
1967require されるアイテムのファイル名です (パッケージ名はパスに変換されます)。
1968このファイル名を変更して、ロードされるファイルを変更できます。
1969実行中にフックが die すると、require の実行がブロックされます。
20481970
2049=item ${^UNICODE}
2050X<${^UNICODE}>
2051
20521971=begin original
20531972
2054Reflects certain Unicode settings of Perl. See L<perlrun>
1973In order to make it easy to perform an action with shared state both
2055documentation for the C<-C> switch for more information about
1974before and after the require keyword was executed the C<require__before>
2056the possible values.
1975hook may return a "post-action" coderef which will in turn be executed when
1976the C<require> completes. This coderef will be executed regardless as to
1977whether the require completed succesfully or threw an exception. It will
1978be called with the filename that was required. You can check %INC to
1979determine if the require was successful. Any other return from the
1980C<require__before> hook will be silently ignored.
20571981
20581982=end original
20591983
2060Perlいくつか Unicode 設定反映します。
1984require キーワードが実行される前と後両方で共有状態アクション
2061設定できるするさらなる情報ついては L<perlrun> の C<-C> オプションを
1985簡単に実行できるようにするため、C<require__before> フックは、
2062参照てくだい。
1986C<require> が完了たときに順番に実行れる「アクション後」の
1987コードリファレンスを返すことができます。
1988このコードリファレンスは、require が正常に完了したか、
1989例外が投げられたかにかかわらず実行されます。
1990これは、require されたファイル名と共に呼び出されます。
1991%INC をチェックして、require が成功したかどうかを判断できます。
1992C<require__before> フックからのその他の戻り値は、暗黙に無視されます。
20631993
20641994=begin original
20651995
2066This variable is set during Perl startup and is thereafter read-only.
1996C<require__before> hooks are called in FIFO order, and if the hook
1997returns a code reference those code references will be called in FILO
1998order. In other words if A requires B requires C, then
1999C<require__before> will be called first for A, then B and then C, and
2000the post-action code reference will executed first for C, then B and
2001then finally A.
20672002
20682003=end original
20692004
2070この変数は Perl 起動時設定され、その後は読み込み専用です。
2005C<require__before> フックは FIFO 順呼び出され、フックが
2006コードリファレンスを返す場合、それらのコードリファレンスは
2007FILO 順に呼び出されます。
2008つまり、A が B を require し、B が C を require する場合、
2009C<require__before> が最初に A に対して呼び出され、次に B, C の順に
2010呼び出され、アクション後のコードリファレンスが最初に C に対して実行され、
2011次に B、最後に A の順に実行されます。
20712012
20722013=begin original
20732014
2074This variable was added in Perl 5.8.2.
2015Well behaved code should ensure that when setting up a
2016C<require__before> hook that any prior installed hook will be called,
2017and that their return value, if a code reference, will be called as
2018well. See L<perlfunc/require> for an example implementation.
20752019
20762020=end original
20772021
2078この変数 Perl 5.8.2 で追加されました。
2022適切に動作するコードで、C<require__before> フックを設定するときに、
2023以前にインストールされたフックが呼び出され、コードリファレンスの場合は
2024その戻り値も呼び出されるようにする必要があります。
2025実装例については、L<perlfunc/require> を参照してください。
20792026
2080=item ${^UTF8CACHE}
2027=item require__after
2081X<${^UTF8CACHE}>
20822028
20832029=begin original
20842030
2085This variable controls the state of the internal UTF-8 offset caching code.
2031The routine indicated by C<${^HOOK}{require__after}> is called by
20861 for on (the default), 0 for off, -1 to debug the caching code by checking
2032C<require> B<after> the require completes. It is called with a single
2087all its results against linear scans, and panicking on any discrepancy.
2033argument, the filename for the item being required (package names are
2034converted to paths). It is executed when the C<require> completes,
2035either via exception or via completion of the require statement, and you
2036can check C<%INC> to determine if the require was successful.
20882037
20892038=end original
20902039
2091この変数は内部 UTF-8 オフセットキャッシュコドの状態を制御ます。
2040C<${^HOOK}{require__after}> で示されるルチンは、require が完了
20921 はオン(デフォルト)、0 はオフ、-1 は全の結果を線形走査と比較して、
2041B<後> C<require> によっ呼び出されます。
2093矛盾があれば異常終了する、という形でキャッシュコドをデバッグします
2042このルチンは単一の引数で呼び出されます;
2043require されるアイテムのファイル名です (パッケージ名はパスに変換されます)。
2044このルーチンは、例外または require 文の完了によって
2045C<require> が完了したときに実行されます;
2046C<%INC> をチェックして、require が成功したかどうかを判断できます。
20942047
20952048=begin original
20962049
2097This variable was added in Perl 5.8.9.
2050The C<require__after> hook is called for each required file in FILO
2051order. In other words if A requires B requires C, then C<require__after>
2052will be called first for C, then B and then A.
20982053
20992054=end original
21002055
2101この変数は Perl 5.8.9 で追加されまし
2056C<require__after> フックは、require されたファイルごとに FILO 順で
2057呼び出されます。
2058つまり、A が B を require し、B が C を require する場合、
2059C<require__after> が最初に C に対して呼び出され、次に B、次に A に対して
2060呼び出されます。
21022061
2103=item ${^UTF8LOCALE}
2062=back
2104X<${^UTF8LOCALE}>
21052063
2106=begin original
2064=item $BASETIME
21072065
2108This variable indicates whether a UTF-8 locale was detected by perl at
2066=item $^T
2109startup. This information is used by perl when it's in
2067X<$^T> X<$BASETIME>
2110adjust-utf8ness-to-locale mode (as when run with the C<-CL> command-line
2111switch); see L<perlrun> for more info on this.
21122068
2113=end original
2114
2115この変数は、起動時に perl によって UTF-8 ロケールが検出されたかどうかを
2116示します。
2117この情報は(C<-CL> コマンドラインスイッチで起動されることによって)
2118「utf8 性をロケールに合わせる」モードのときに perl によって使われます;
2119これに関するさらなる情報は L<perlrun> を参照してください。
2120
21212069=begin original
21222070
2123This variable was added in Perl 5.8.8.
2071The time at which the program began running, in seconds since the
2072epoch (beginning of 1970). The values returned by the B<-M>, B<-A>,
2073and B<-C> filetests are based on this value.
21242074
21252075=end original
21262076
2127変数は Perl 5.8.8 追加されました。
2077プログラムを実行開始した時刻を、紀元 (1970年始め) からの秒数
2078示したものです。
2079ファイルテスト B<-M>、B<-A>、B<-C> で返される値は、この値に基づいています。
21282080
21292081=item $PERL_VERSION
21302082
21312083=item $^V
21322084X<$^V> X<$PERL_VERSION>
21332085
2086=for comment
2087These are documented in the generated file lib/Config.pod. This looks
2088like as good a place as any to give notice that they are documented.
2089
21342090=begin original
21352091
21362092The revision, version, and subversion of the Perl interpreter,
2137represented as a C<version> object.
2093represented as a L<version> object.
21382094
21392095=end original
21402096
2141C<version> オブジェクトとして表現される revision, version, subversion。
2097L<version> オブジェクトとして表現される Perl インタプリタの
2098revision, version, subversion。
21422099
21432100=begin original
21442101
2145This variable first appeared in perl 5.6.0; earlier versions of perl
2102This variable first appeared in perl v5.6.0; earlier versions of perl
2146will see an undefined value. Before perl 5.10.0 C<$^V> was represented
2103will see an undefined value. Before perl v5.10.0 C<$^V> was represented
2147as a v-string.
2104as a v-string rather than a L<version> object.
21482105
21492106=end original
21502107
2151この変数は perl 5.6.0 で最初に現れました; それより前のバージョンでは
2108この変数は perl v5.6.0 で最初に現れました; それより前のバージョンでは
21522109未定義値となります。
2153perl 5.10.0 以前では C<$^V> は v-string 形式表現されます。
2110perl v5.10.0 以前では C<$^V> は L<version> オブジェクトはなく
2111v-string 形式で表現されます。
21542112
21552113=begin original
21562114
21572115C<$^V> can be used to determine whether the Perl interpreter executing
2158a script is in the right range of versions. For example:
2116a script is in the right range of versions. For example:
21592117
21602118=end original
21612119
21622120C<$^V> はスクリプトを実行している Perl インタプリタのバージョンが
21632121正しい範囲に入っているかを調べるのに使えます。
2164例:
2122えば:
21652123
2166 warn "Hashes not randomized!\n" if !$^V or $^V lt v5.8.1
2124 warn "Hashes not randomized!\n" if !$^V or $^V lt v5.8.1
21672125
21682126=begin original
21692127
2170To convert C<$^V> into its string representation use C<sprintf()>'s
2128While version objects overload stringification, to portably convert
2171C<"%vd"> conversion:
2129C<$^V> into its string representation, use C<sprintf()>'s C<"%vd">
2130conversion, which works for both v-strings or version objects:
21722131
21732132=end original
21742133
2175C<$^V> を文字列表現に変換するには C<sprintf()> の C<"%vd"> 変換を使います:
2134移植性がある形で C<$^V> を文字列表現に変換するため
2135バージョンオブジェクトは文字列化をオーバーロードしますが、
2136v-文字列とバージョンオブジェクトの療養で動作する
2137C<sprintf()> の C<"%vd"> 変換を使ってください。
21762138
2177 printf "version is v%vd\n", $^V; # Perl's version
2178
21792139=begin original
21802140
2181See the documentation of C<use VERSION> and C<require VERSION>
2141 printf "version is v%vd\n", $^V; # Perl's version
2182for a convenient way to fail if the running Perl interpreter is too old.
21832142
21842143=end original
21852144
2186実行する Perl タプリタが古すぎる場合に終了する便利な方法に
2145 printf "version is v%vd\n", $^V; # Perl のバージョ
2187ついては C<use VERSION> と C<require VERSION> のドキュメントを
2188参照して下さい。
21892146
21902147=begin original
21912148
2192See also C<$]> for an older representation of the Perl version.
2149See the documentation of C<use VERSION> and C<require VERSION>
2150for a convenient way to fail if the running Perl interpreter is too old.
21932151
21942152=end original
21952153
2196Perl バージョい表現については C<$]> も参照して下さい。
2154実行する Perl タプリタがすぎる場合終了する便利な方法については
2155C<use VERSION> と C<require VERSION> のドキュメントを参照して下さい。
21972156
21982157=begin original
21992158
2200This variable was added in Perl 5.6.
2159See also C<L</$]>> for a decimal representation of the Perl version.
22012160
22022161=end original
22032162
2204この変数は Perl 5.6 で追加されま
2163Perl バージョンの 10 進表現については C<L</$]>> も参照て下さい
22052164
22062165=begin original
22072166
2208Mnemonic: use ^V for Version Control.
2167The main advantage of C<$^V> over C<$]> is that, for Perl v5.10.0 or
2168later, it overloads operators, allowing easy comparison against other
2169version representations (e.g. decimal, literal v-string, "v1.2.3", or
2170objects). The disadvantage is that prior to v5.10.0, it was only a
2171literal v-string, which can't be easily printed or compared, whereas
2172the behavior of C<$]> is unchanged on all versions of Perl.
22092173
22102174=end original
22112175
2212記憶法: ^V をバージョンコントロールに使います。
2176Perl 5.10.0 以降での、C<$]> に対する C<$^V> の主な利点は、これは演算子
2177オーバーロードするので、他のバージョン表現 (例えば 10 進数、
2178リテラルな v-文字列、"v1.2.3"、オブジェクト)との比較が簡単であることです。
2179v5.10.0 より前での欠点は、これは単なるリテラルな v-文字列であるため、
2180簡単に表示したり比較したり出来ないことです; 一方、
2181C<$]> の振る舞いは全てのバージョンの Perl で変化しません。
22132182
2214=item ${^WIN32_SLOPPY_STAT}
2215X<${^WIN32_SLOPPY_STAT}> X<sitecustomize> X<sitecustomize.pl>
2216
22172183=begin original
22182184
2219If this variable is set to a true value, then C<stat()> on Windows will
2185Mnemonic: use ^V for a version object.
2220not try to open the file. This means that the link count cannot be
2221determined and file attributes may be out of date if additional
2222hardlinks to the file exist. On the other hand, not opening the file
2223is considerably faster, especially for files on network drives.
22242186
22252187=end original
22262188
2227この変数が真の値にセットされると、Windows での C<stat()> はファイル
2189記憶法: ^Vバージョンオブジェクトに使います。
2228オープンしようとはしません。
2229これは、このファイルへの追加のハードリンクが存在する場合、リンクカウントを
2230決定できませんし、ファイル属性が古いものになるかもしれないことを
2231意味します。
2232一方、ファイルを開かないので、(特にファイルがネットワークドライブにある
2233場合は)大幅に高速です。
22342190
2235=begin original
2236
2237This variable could be set in the F<sitecustomize.pl> file to
2238configure the local Perl installation to use "sloppy" C<stat()> by
2239default. See the documentation for B<-f> in
2240L<perlrun|perlrun/"Command Switches"> for more information about site
2241customization.
2242
2243=end original
2244
2245デフォルトで「ずさんな」C<stat()> を使うために、この変数は、ローカルな
2246Perl を設定するための F<sitecustomize.pl> で設定できます。
2247サイトカスタマイズに関するさらなる情報については
2248L<perlrun|perlrun/"Command Switches"> の B<-f> を参照してください。
2249
2250=begin original
2251
2252This variable was added in Perl 5.10.
2253
2254=end original
2255
2256この変数は Perl 5.10 で追加されました。
2257
22582191=item $EXECUTABLE_NAME
22592192
22602193=item $^X
22612194X<$^X> X<$EXECUTABLE_NAME>
22622195
22632196=begin original
22642197
22652198The name used to execute the current copy of Perl, from C's
22662199C<argv[0]> or (where supported) F</proc/self/exe>.
22672200
22682201=end original
22692202
22702203Perl バイナリ自身が実行された時の名前を C の argv[0] または (対応していれば)
22712204F</proc/self/exe> から持ってきたものです。
22722205
22732206=begin original
22742207
22752208Depending on the host operating system, the value of C<$^X> may be
22762209a relative or absolute pathname of the perl program file, or may
22772210be the string used to invoke perl but not the pathname of the
2278perl program file. Also, most operating systems permit invoking
2211perl program file. Also, most operating systems permit invoking
22792212programs that are not in the PATH environment variable, so there
2280is no guarantee that the value of C<$^X> is in PATH. For VMS, the
2213is no guarantee that the value of C<$^X> is in PATH. For VMS, the
22812214value may or may not include a version number.
22822215
22832216=end original
22842217
22852218ホスト OS に依存して、C<$^X> の値は perl プログラムファイルの絶対パスかも
22862219しれませんし、相対パスかもしれませんし、perl を起動するために使われる
22872220文字列ではありますが perl プログラムファイルのパス名ではないかもしれません。
22882221また、ほとんどの OS は PATH 環境変数にない位置のプログラムを起動することを
22892222許しているので、C<$^X> の値が PATH にある保証はありません。
22902223VMS では、この値はバージョン番号を含む場合も含まない場合もあります。
22912224
22922225=begin original
22932226
22942227You usually can use the value of C<$^X> to re-invoke an independent
22952228copy of the same perl that is currently running, e.g.,
22962229
22972230=end original
22982231
22992232通常は、現在実行中のものと同じ perl の独立したコピーを再起動するために
23002233C<$^X> の値を使えます; つまり:
23012234
2302 @first_run = `$^X -le "print int rand 100 for 1..100"`;
2235 @first_run = `$^X -le "print int rand 100 for 1..100"`;
23032236
23042237=begin original
23052238
23062239But recall that not all operating systems support forking or
23072240capturing of the output of commands, so this complex statement
23082241may not be portable.
23092242
23102243=end original
23112244
23122245しかし、全ての OS が fork やコマンドの出力の捕捉に対応しているわけでは
23132246ないので、この複雑な文は移植性がないかもしれないことを忘れないでください。
23142247
23152248=begin original
23162249
23172250It is not safe to use the value of C<$^X> as a path name of a file,
23182251as some operating systems that have a mandatory suffix on
23192252executable files do not require use of the suffix when invoking
2320a command. To convert the value of C<$^X> to a path name, use the
2253a command. To convert the value of C<$^X> to a path name, use the
23212254following statements:
23222255
23232256=end original
23242257
2325C<$^X> の値をファイルのパス名として使うのは安全ではありません;
2258C<$^X> の値をファイルのパス名として使うのは安全ではありません; 実行ファイルに
2326実行ファイルに固定の接尾辞があり、コマンドの起動時には接尾辞が不要な OS も
2259固定の接尾辞があり、コマンドの起動時には接尾辞が不要な OS もあるからです。
2327あるからです。
23282260C<$^X> の値をパス名に変換するには、以下のコードを使ってください:
23292261
2330 # Build up a set of file names (not command names).
2262=begin original
2331 use Config;
2332 my $this_perl = $^X;
2333 if ($^O ne 'VMS') {
2334 $this_perl .= $Config{_exe}
2335 unless $this_perl =~ m/$Config{_exe}$/i;
2336 }
23372263
2264 # Build up a set of file names (not command names).
2265 use Config;
2266 my $this_perl = $^X;
2267 if ($^O ne 'VMS') {
2268 $this_perl .= $Config{_exe}
2269 unless $this_perl =~ m/$Config{_exe}$/i;
2270 }
2271
2272=end original
2273
2274 # (コマンド名ではなく)ファイル名を構築する。
2275 use Config;
2276 my $this_perl = $^X;
2277 if ($^O ne 'VMS') {
2278 $this_perl .= $Config{_exe}
2279 unless $this_perl =~ m/$Config{_exe}$/i;
2280 }
2281
23382282=begin original
23392283
23402284Because many operating systems permit anyone with read access to
23412285the Perl program file to make a copy of it, patch the copy, and
23422286then execute the copy, the security-conscious Perl programmer
23432287should take care to invoke the installed copy of perl, not the
2344copy referenced by C<$^X>. The following statements accomplish
2288copy referenced by C<$^X>. The following statements accomplish
23452289this goal, and produce a pathname that can be invoked as a
23462290command or referenced as a file.
23472291
23482292=end original
23492293
2350多くの OS が Perl のプログラムファイルのコピーを作って、コピーに
2294多くの OS が Perl のプログラムファイルのコピーを作って、コピーにパッチを当て、
2351パッチを当て、それを実行するための読み込み権限を全員に与えているので、
2295それを実行するための読み込み権限を全員に与えているので、セキュリティ
2352セキュリティ意識のある Perl プログラマは C<$^X> で参照されているコピーではなく、
2296意識のある Perl プログラマは C<$^X> で参照されているコピーではなく、
23532297インストールされている perl を起動するように気をつけるべきです。
23542298以下のコードはこの目的を達成し、コマンドとして起動したりファイルとして
23552299参照するためのパス名を作成します。
23562300
2357 use Config;
2301 use Config;
2358 my $secure_perl_path = $Config{perlpath};
2302 my $secure_perl_path = $Config{perlpath};
2359 if ($^O ne 'VMS') {
2303 if ($^O ne 'VMS') {
2360 $secure_perl_path .= $Config{_exe}
2304 $secure_perl_path .= $Config{_exe}
2361 unless $secure_perl_path =~ m/$Config{_exe}$/i;
2305 unless $secure_perl_path =~ m/$Config{_exe}$/i;
2362 }
2306 }
23632307
23642308=back
23652309
23662310=head2 Variables related to regular expressions
23672311
23682312(正規表現に関する変数)
23692313
23702314=begin original
23712315
23722316Most of the special variables related to regular expressions are side
2373effects. Perl sets these variables when it has a successful match, so
2317effects. Perl sets these variables when it has completed a match
2374you should check the match result before using them. For instance:
2318successfully, so you should check the match result before using them.
2319For instance:
23752320
23762321=end original
23772322
23782323正規表現に関連する特殊変数のほとんどは副作用です。
23792324Perl はマッチングに成功したときにこれらの変数を設定するので、変数を
23802325使う前にマッチングの結果をチェックするべきです。
23812326例えば:
23822327
2383 if( /P(A)TT(ER)N/ ) {
2328 if( /P(A)TT(ER)N/ ) {
2384 print "I found $1 and $2\n";
2329 print "I found $1 and $2\n";
2385 }
2330 }
23862331
23872332=begin original
23882333
2389These variables are read-only and dynamically-scoped, unless we note
2334These variables are read-only and behave similarly to a dynamically
2390otherwise.
2335scoped variable, with only a few exceptions which are explicitly
2336documented as behaving otherwise. See the following section for more
2337details.
23912338
23922339=end original
23932340
2394これらの変数は特に記さない限り読み込み専用で動スコープ持ちます。
2341これらの変数は、異る振る舞を明示に記しているいくつかの例外除いて、
2342読み込み専用で動的スコープを持つ変数と同様に振る舞います。
23952343
2344=head3 Scoping Rules of Regex Variables
2345X<Scoping Rules of Regex Variables>
2346
2347(正規表現変数のスコープ規則)
2348
23962349=begin original
23972350
2398The dynamic nature of the regular expression variables means that
2351Regular expression variables allow the programmer to access the state of
2399their value is limited to the block that they are in, as demonstrated
2352the most recent I<successful> regex match in the current dynamic scope.
2400by this bit of code:
24012353
24022354=end original
24032355
2404正規表現変数の動的な特性により、以下のコード片示されているよう
2356正規表現変数を使うと、プログラマは現在の動的コープ内最後
2405変数の値はブロク内制限されます:
2357I<成功した> 正規表現マチングの状態アクセスできます
24062358
2407 my $outer = 'Wallace and Grommit';
2359=begin original
2408 my $inner = 'Mutt and Jeff';
24092360
2410 my $pattern = qr/(\S+) and (\S+)/;
2361The variables themselves are global and unscoped, but the data they
2362access is scoped similarly to dynamically scoped variables, in that
2363every successful match behaves as though it localizes a global state
2364object to the current block or file scope.
2365(See L<perlsyn/"Compound Statements"> for more details on dynamic
2366scoping and the C<local> keyword.)
24112367
2412 sub show_n { print "\$1 is $1; \$2 is $2\n" }
2368=end original
24132369
2414 {
2370変数自体はグローバルでスコープはありませんが、変数がアクセスする
2415 OUTER:
2371データは動的スコープ変数と同様にスコープがあります;
2416 show_n() if $outer =~ m/$pattern/;
2372つまり、マッチングが成功するたびに、グローバル状態オブジェクトが
2373現在のブロックまたはファイルスコープにローカル化されたかのように
2374動作します。
2375(動的スコープと C<local> キーワードの詳細については、
2376L<perlsyn/"Compound Statements"> を参照してください。)
24172377
2418 INNER: {
2378=begin original
2419 show_n() if $inner =~ m/$pattern/;
2420 }
24212379
2422 show_n();
2380A I<successful match> includes any successful match performed by the
2423 }
2381search and replace operator C<s///> as well as those performed by the
2382C<m//> operator.
24242383
2384=end original
2385
2386I<成功したマッチング> には、C<m//> 演算子によって実行されたものに加えて、
2387検索および置換演算子 C<s///> によって実行されたすべての成功した
2388マッチングが含まれます。
2389
24252390=begin original
24262391
2427The output shows that while in the C<OUTER> block, the values of C<$1>
2392Consider the following code:
2428and C<$2> are from the match against C<$outer>. Inside the C<INNER>
2429block, the values of C<$1> and C<$2> are from the match against
2430C<$inner>, but only until the end of the block (i.e. the dynamic
2431scope). After the C<INNER> block completes, the values of C<$1> and
2432C<$2> return to the values for the match against C<$outer> even though
2433we have not made another match:
24342393
24352394=end original
24362395
2437出力から分かることは、C<OUTER> ブロック間では C<$1> と C<$2> の値は
2396コードを考えます:
2438C<$outer> に対するマッチングからのものになります。
2439C<INNER> ブロックの内側では、C<$1> と C<$2> の値は C<$inner> での
2440マッチングからのものになりますが、ブロックの最後までです (つまり、
2441動的スコープを持ちます)。
2442C<INNER> ブロックの終了後、C<$1> と C<$2> の値は、他のマッチングがなくても
2443C<$outer> に対するマッチングからのものになります:
24442397
2445 $1 is Wallace; $2 is Grommit
2398 my @state;
2446 $1 is Mutt; $2 is Jeff
2399 sub matchit {
2447 $1 is Wallace; $2 is Grommit
2400 push @state, $1; # pushes "baz"
2401 my $str = shift;
2402 $str =~ /(zat)/; # matches "zat"
2403 push @state, $1; # pushes "zat"
2404 }
24482405
2406 {
2407 $str = "foo bar baz blorp zat";
2408 $str =~ /(foo)/; # matches "foo"
2409 push @state, $1; # pushes "foo"
2410 {
2411 $str =~ /(pizza)/; # does NOT match
2412 push @state, $1; # pushes "foo"
2413 $str =~ /(bar)/; # matches "bar"
2414 push @state, $1; # pushes "bar"
2415 $str =~ /(baz)/; # matches "baz"
2416 matchit($str); # see above
2417 push @state, $1; # pushes "baz"
2418 }
2419 $str =~ s/noodles/rice/; # does NOT match
2420 push @state, $1; # pushes "foo"
2421 $str =~ s/(blorp)/zwoop/; # matches "blorp"
2422 push @state, $1; # pushes "blorp"
2423 }
2424 # the following prints "foo, foo, bar, baz, zat, baz, foo, blorp"
2425 print join ",", @state;
2426
24492427=begin original
24502428
2451Due to an unfortunate accident of Perl's implementation, C<use
2429Notice that each successful match in the exact same scope overrides the
2452English> imposes a considerable performance penalty on all regular
2430match context of the previous successful match, but that unsuccessful
2453expression matches in a program because it uses the C<$`>, C<$&>, and
2431matches do not. Also note that in an inner nested scope the previous
2454C<$'>, regardless of whether they occur in the scope of C<use
2432state from an outer dynamic scope persists until it has been overriden
2455English>. For that reason, saying C<use English> in libraries is
2433by another successful match, but that when the inner nested scope exits
2456strongly discouraged unless you import it without the match variables:
2434whatever match context was in effect before the inner successful match
2435is restored when the scope concludes.
24572436
24582437=end original
24592438
2460Perl の実装におけ不幸な事故よりC<use English> は
2439まったく同じスコープ内でマッチングが成功すたびに、以前の成功した
2461C<$`>, C<$&>, C<$'> を使うプロラム中の全ての
2440マッチングマッチングコンテキストは上書きされますが失敗したマッチン
2462正規表現マッチングにおいてかなりの性能低下を引こします;
2441上書されないとに注意てください。
2463れは C<use English> のスコープどうかに関わりません。
2442また、内側のネストさたスコープで、外側動的スコープからの
2464理由により、ライブラリで C<use English> を使うのは、マッチング変数を
2443以前状態は、別の成功したマッチングによって上書きされるまで持続しますが、
2465使わずにインポートするのでない限りできだけ避けてください。
2444内側のネスされたスコープが終了すると、内側成功したマッチングが終了す
2445前に有効であったマッチングコンテキストが復元されます。
24662446
2467 use English '-no_match_vars'
2447=begin original
24682448
2449It is a known issue that C<goto LABEL> may interact poorly with the
2450dynamically scoped match context. This may not be fixable, and is
2451considered to be one of many good reasons to avoid C<goto LABEL>.
2452
2453=end original
2454
2455C<goto LABEL> が動的スコープマッチングコンテキストとうまく
2456相互作用しない可能性があることは既知の問題です。
2457これは修正できない可能性があり、C<goto LABEL> を避ける多くの正当な
2458理由の一つと考えられています。
2459
2460=head3 Performance issues
2461
2462(性能問題)
2463
24692464=begin original
24702465
2471The C<Devel::NYTProf> and C<Devel::FindAmpersand>
2466Traditionally in Perl, any use of any of the three variables C<$`>, C<$&>
2472modules can help you find uses of these
2467or C<$'> (or their C<use English> equivalents) anywhere in the code, caused
2473problematic match variables in your code.
2468all subsequent successful pattern matches to make a copy of the matched
2469string, in case the code might subsequently access one of those variables.
2470This imposed a considerable performance penalty across the whole program,
2471so generally the use of these variables has been discouraged.
24742472
24752473=end original
24762474
2477C<Devel::NYTProf> モジュールと C<Devel::FindAmpersand> モジュールは
2475Perl では伝統的に、C<$`>, C<$&>, C<$'> (または C<use English> での
2478コードのこれらの問題のあるマッチング変数の仕様を探す助けなります。
2476等価物) をコードのどこか使うと、コードが引き続いてこれらの変数に
2477アクセスするかもしれないので、引き続くすべての成功したパターンマッチングで
2478マッチングした文字列のコピーを作ります。
2479これはプログラム全体に対してかなりの性能上の負荷を掛けるので、一般的に
2480これらの変数の使用は非推奨です。
24792481
24802482=begin original
24812483
2482Since Perl 5.10, you can use the C</p> match operator flag and the
2484In Perl 5.6.0 the C<@-> and C<@+> dynamic arrays were introduced that
2483C<${^PREMATCH}>, C<${^MATCH}>, and C<${^POSTMATCH}> variables instead
2485supply the indices of successful matches. So you could for example do
2484so you only suffer the performance penalties.
2486this:
24852487
24862488=end original
24872489
2488Perl 5.10 からC</p> マッチングフラグ
2490Perl 5.6.0 では、マッチングに成功したインデックスを提供する C<@->
2489C<${^PREMATCH}>, C<${^MATCH}>, C<${^POSTMATCH}> 変数を代わりに使えて、
2491C<@+> 動的配列が導入されました。
2490パフォーマンスペナルティだけを受けます
2492それで、たとえばこようにできます:
24912493
2494 $str =~ /pattern/;
2495
2496 print $`, $&, $'; # bad: performance hit
2497
2498 print # good: no performance hit
2499 substr($str, 0, $-[0]),
2500 substr($str, $-[0], $+[0]-$-[0]),
2501 substr($str, $+[0]);
2502
2503=begin original
2504
2505In Perl 5.10.0 the C</p> match operator flag and the C<${^PREMATCH}>,
2506C<${^MATCH}>, and C<${^POSTMATCH}> variables were introduced, that allowed
2507you to suffer the penalties only on patterns marked with C</p>.
2508
2509=end original
2510
2511Perl 5.10.0 で C</p> マッチング演算子フラグと C<${^PREMATCH}>,
2512C<${^MATCH}>, C<${^POSTMATCH}> 変数が導入され、C</p> でマークされた
2513パターンのみが負荷を被るようにできるようになりました。
2514
2515=begin original
2516
2517In Perl 5.18.0 onwards, perl started noting the presence of each of the
2518three variables separately, and only copied that part of the string
2519required; so in
2520
2521=end original
2522
2523Perl 5.18.0 以降では、perl は三つの変数の存在を別々に注意するようになり、
2524必要な部分文字列のみをコピーするようになりました; 従って、次の場合は
2525
2526 $`; $&; "abcdefgh" =~ /d/
2527
2528=begin original
2529
2530perl would only copy the "abcd" part of the string. That could make a big
2531difference in something like
2532
2533=end original
2534
2535perl は文字列のうち "abcd" の部分のみをコピーします。
2536これは次のようなものとは大きな違いになります
2537
2538 $str = 'x' x 1_000_000;
2539 $&; # whoops
2540 $str =~ /x/g # one char copied a million times, not a million chars
2541
2542=begin original
2543
2544In Perl 5.20.0 a new copy-on-write system was enabled by default, which
2545finally fixes most of the performance issues with these three variables, and
2546makes them safe to use anywhere.
2547
2548=end original
2549
2550Perl 5.20.0 では新しいコピーオンライトシステムがデフォルトで有効になり、
2551これらの変数に関するほとんどの性能問題は最終的に修正され、
2552これらをどこで使っても安全になりました。
2553
2554=begin original
2555
2556The C<Devel::NYTProf> and C<Devel::FindAmpersand> modules can help you
2557find uses of these problematic match variables in your code.
2558
2559=end original
2560
2561C<Devel::NYTProf> と C<Devel::FindAmpersand> のモジュールは、コード中に
2562これらの問題のあるマッチング変数の使用を探す助けになります。
2563
24922564=over 8
24932565
24942566=item $<I<digits>> ($1, $2, ...)
2495X<$1> X<$2> X<$3>
2567X<$1> X<$2> X<$3> X<$I<digits>>
24962568
24972569=begin original
24982570
2571
24992572Contains the subpattern from the corresponding set of capturing
2500parentheses from the last successful pattern match, not counting patterns
2573parentheses from the last successful pattern match in the current
2501matched in nested blocks that have been exited already.
2574dynamic scope. (See L</Scoping Rules of Regex Variables>.)
25022575
25032576=end original
25042577
2505最後に成功したパターンマッチングで対応する括弧のサブパターンにマッチングした
2578現在の動的スコープで、最後に成功したパターンマッチングで対応する括弧の
2506文字列が入っているが、既に抜けてしったブロックでの
2579サブパターンにマッチングした文字列が入っています。
2507パターンマッチングは勘定に入れません
2580(L</Scoping Rules of Regex Variables> を参照してください)
25082581
25092582=begin original
25102583
2511These variables are read-only and dynamically-scoped.
2584Note there is a distinction between a capture buffer which matches
2585the empty string a capture buffer which is optional. Eg, C<(x?)> and
2586C<(x)?> The latter may be undef, the former not.
25122587
25132588=end original
25142589
2515これらの変数はべて読み込み専用で動的なスコーを持ちます。
2590空文字列にマッチングる捕捉バッファとションの捕捉バッファの
2591違いに注意してください。
2592例えば、C<(x?)> と C<(x)?> では、後者は undef かもしれませんが、
2593前者は違います。
25162594
25172595=begin original
25182596
2597These variables are read-only.
2598
2599=end original
2600
2601これらの変数はすべて読み込み専用です。
2602
2603=begin original
2604
25192605Mnemonic: like \digits.
25202606
25212607=end original
25222608
2523(記憶法: \(数字) のようなもの。)
2609記憶法: \(数字) のようなもの。
25242610
2611=item @{^CAPTURE}
2612X<@{^CAPTURE}> X<@^CAPTURE>
2613
2614=begin original
2615
2616An array which exposes the contents of the capture buffers, if any, of
2617the last successful pattern match, not counting patterns matched
2618in nested blocks that have been exited already.
2619
2620=end original
2621
2622最後に成功したパターンマッチングの (もしあれば) 捕捉バッファの内容を
2623露出させた配列; 既に終了したネストしたブロックの中でマッチングしたパターンは
2624考慮しません。
2625
2626=begin original
2627
2628Note that the 0 index of C<@{^CAPTURE}> is equivalent to C<$1>, the 1 index
2629is equivalent to C<$2>, etc.
2630
2631=end original
2632
2633C<@{^CAPTURE}> の添え字 0 は C<$1> と等価、
2634添え字 1 は C<$2> と等価、などであることに注意してください。
2635
2636 if ("foal"=~/(.)(.)(.)(.)/) {
2637 print join "-", @{^CAPTURE};
2638 }
2639
2640=begin original
2641
2642should output "f-o-a-l".
2643
2644=end original
2645
2646これは "f-o-a-l" を出力します。
2647
2648=begin original
2649
2650See also L<<< /$<I<digits>> ($1, $2, ...) >>>, L</%{^CAPTURE}> and
2651L</%{^CAPTURE_ALL}>.
2652
2653=end original
2654
2655L<<< /$<I<数字>> ($1, $2, ...) >>>, L</%{^CAPTURE}>,
2656L</%{^CAPTURE_ALL}> も参照してください。
2657
2658=begin original
2659
2660Note that unlike most other regex magic variables there is no single
2661letter equivalent to C<@{^CAPTURE}>. Also be aware that when
2662interpolating subscripts of this array you B<must> use the demarcated
2663variable form, for instance
2664
2665=end original
2666
2667その他のほとんどの正規表現マジカル変数と異なり、
2668C<@{^CAPTURE}> と等価な単一文字変数はないことに注意してください。
2669また、この配列の添え字を変数展開するときは、境界を定める変数形式を
2670B<使わなければならない> ことにも注意してください; 例えば:
2671
2672 print "${^CAPTURE[0]}"
2673
2674=begin original
2675
2676see L<perldata/"Demarcated variable names using braces"> for more
2677information on this form and its uses.
2678
2679=end original
2680
2681この形式とその使用法に関するさらなる情報については
2682L<perldata/"Demarcated variable names using braces"> を参照してください。
2683
2684=begin original
2685
2686This variable was added in 5.25.7
2687
2688=end original
2689
2690これは 5.25.7 で追加されました。
2691
2692=begin original
2693
2694If you need access to this functionality in older Perls you can use this
2695function immediately after your regexp.
2696
2697=end original
2698
2699古い Perl でこの機能にアクセスする必要がある場合は、
2700正規表現の直後にこの関数を使えます。
2701
2702 sub get_captures {
2703 no strict 'refs';
2704
2705 my $last_idx = scalar(@-) - 1;
2706 my @arr = 1 .. $last_idx;
2707 my @ret = map { $$_; } @arr;
2708
2709 return @ret;
2710 }
2711
25252712=item $MATCH
25262713
25272714=item $&
25282715X<$&> X<$MATCH>
25292716
25302717=begin original
25312718
2532The string matched by the last successful pattern match (not counting
2719The string matched by the last successful pattern match.
2533any matches hidden within a BLOCK or C<eval()> enclosed by the current
2720(See L</Scoping Rules of Regex Variables>.)
2534BLOCK).
25352721
25362722=end original
25372723
2538最後に成功したパターンマッチでマッチした文字列 (現在の
2724最後に成功したパターンマッチでマッチした文字列
2539BLOCK で囲まれた BLOCK や C<eval()> で隠れている部分でのマッチは
2725(L</Scoping Rules of Regex Variables> を参照しくださ。)
2540勘定に入れません)。
25412726
25422727=begin original
25432728
2544The use of this variable anywhere in a program imposes a considerable
2729See L</Performance issues> above for the serious performance implications
2545performance penalty on all regular expression matches. To avoid this
2730of using this variable (even once) in your code.
2546penalty, you can extract the same substring by using L</@->. Starting
2547with Perl 5.10, you can use the </p> match flag and the C<${^MATCH}>
2548variable to do the same thing for particular match operations.
25492731
25502732=end original
25512733
2552この変数をプログラムのどこかで使うと、プログラム中の正規表現
2734この変数を(一度も)使うによる重大な性能問題についは前述した
2553マッチングにおいてかなりの性能低下引き起こます
2735L</Performance issues> 参照てください
2554このペナルティを避けるために、同じ部分文字列を L</@-> を使って
2555抽出できます。
2556Perl 5.10 から、C</p> マッチングフラグと C<${^MATCH}> 変数を
2557特定のマッチング演算子について同じことをするために使えます。
25582736
25592737=begin original
25602738
2561This variable is read-only and dynamically-scoped.
2739This variable is read-only, and its value is dynamically scoped.
25622740
25632741=end original
25642742
2565この変数は読み込み専用で動的スコープを持ちます。
2743この変数は読み込み専用で、その値は動的スコープを持ちます。
25662744
25672745=begin original
25682746
25692747Mnemonic: like C<&> in some editors.
25702748
25712749=end original
25722750
25732751記憶法: あるエディタの C<&> ようなもの。
25742752
25752753=item ${^MATCH}
25762754X<${^MATCH}>
25772755
25782756=begin original
25792757
2580This is similar to C<$&> (C<$MATCH>) except that it does not incur the
2758It is only guaranteed to return a defined value when the pattern was
2581performance penalty associated with that variable, and is only guaranteed
2759compiled or executed with the C</p> modifier.
2582to return a defined value when the pattern was compiled or executed with
2583the C</p> modifier.
25842760
25852761=end original
25862762
2587これは C<$&> (C<$MATCH>) と同様ですが、この変数と関連けられた性能上の
2763パターンが C</p> 修飾子きでコンパイルまたは実行された場合、
2588ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された
2764定義された値が返ることだけが保証されます。
2589場合にのみ定義された値を返すことが保証されます。
25902765
25912766=begin original
25922767
2593This variable was added in Perl 5.10.
2768This is similar to C<$&> (C<$MATCH>) except that to use it you must
2769use the C</p> modifier when executing the pattern, and it does not incur
2770the performance penalty associated with that variable.
25942771
25952772=end original
25962773
2597の変数Perl 5.10追加されました。
2774C<$&> (C<$MATCH>) と同様すが、
2775パターンを実行するときに C</p> 修飾子を使わなければならず、
2776この変数と関連付けられた性能上のペナルティを被りません。
25982777
25992778=begin original
26002779
2601This variable is read-only and dynamically-scoped.
2780See L</Performance issues> above.
26022781
26032782=end original
26042783
2605この変数は読み込み専用で動的スコープ持ちます
2784前述した L</Performance issues> 参照してください
26062785
2786=begin original
2787
2788This variable was added in Perl v5.10.0.
2789
2790=end original
2791
2792この変数は Perl v5.10.0 で追加されました。
2793
2794=begin original
2795
2796This variable is read-only, and its value is dynamically scoped.
2797
2798=end original
2799
2800この変数は読み込み専用で、その値は動的スコープを持ちます。
2801
26072802=item $PREMATCH
26082803
26092804=item $`
2610X<$`> X<$PREMATCH> X<${^PREMATCH}>
2805X<$`> X<$PREMATCH>
26112806
26122807=begin original
26132808
26142809The string preceding whatever was matched by the last successful
2615pattern match, not counting any matches hidden within a BLOCK or C<eval>
2810pattern match. (See L</Scoping Rules of Regex Variables>).
2616enclosed by the current BLOCK.
26172811
26182812=end original
26192813
2620最後の成功したパターンマッチ (現在のBLOCK 囲まれ
2814最後の成功したパターンマッチでマッチし部分の前の文字列。
2621BLOCK eval() に隠れている部分でのマッチは勘定に入れません)
2815(L</Scoping Rules of Regex Variables> を参照しください)
2622マッチした部分の前の文字列。
26232816
26242817=begin original
26252818
2626The use of this variable anywhere in a program imposes a considerable
2819See L</Performance issues> above for the serious performance implications
2627performance penalty on all regular expression matches. To avoid this
2820of using this variable (even once) in your code.
2628penalty, you can extract the same substring by using L</@->. Starting
2629with Perl 5.10, you can use the </p> match flag and the
2630C<${^PREMATCH}> variable to do the same thing for particular match
2631operations.
26322821
26332822=end original
26342823
2635この変数をプログラムのどこかで使うと、プログラム中の正規表現
2824この変数を(一度も)使うによる重大な性能問題についは前述した
2636マッチングにおいてかなりの性能低下引き起こます
2825L</Performance issues> 参照てください
2637このペナルティを避けるために、同じ部分文字列を L</@-> を使って
2638抽出できます。
2639Perl 5.10 から、C</p> マッチングフラグと C<${^PREMATCH}> 変数を
2640特定のマッチング演算子について同じことをするために使えます。
26412826
26422827=begin original
26432828
2644This variable is read-only and dynamically-scoped.
2829This variable is read-only, and its value is dynamically scoped.
26452830
26462831=end original
26472832
2648この変数は読み込み専用で動的スコープを持ちます。
2833この変数は読み込み専用で、その値は動的スコープを持ちます。
26492834
26502835=begin original
26512836
26522837Mnemonic: C<`> often precedes a quoted string.
26532838
26542839=end original
26552840
26562841記憶法: C<`> は多くの場合クォートされた文字列の前にある。
26572842
26582843=item ${^PREMATCH}
2659X<$`> X<${^PREMATCH}>
2844X<${^PREMATCH}>
26602845
26612846=begin original
26622847
2663This is similar to C<$`> ($PREMATCH) except that it does not incur the
2848It is only guaranteed to return a defined value when the pattern was
2664performance penalty associated with that variable, and is only guaranteed
2849executed with the C</p> modifier.
2665to return a defined value when the pattern was compiled or executed with
2666the C</p> modifier.
26672850
26682851=end original
26692852
2670これは C<$`> ($PREMATCH) と同様ですが、この変数と関連けられた性能上の
2853パターンが C</p> 修飾子きでコンパイルまたは実行された場合、
2671ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された
2854定義された値が返ることだけが保証されます。
2672場合にのみ定義された値を返すことが保証されます。
26732855
26742856=begin original
26752857
2676This variable was added in Perl 5.10
2858This is similar to C<$`> ($PREMATCH) except that to use it you must
2859use the C</p> modifier when executing the pattern, and it does not incur
2860the performance penalty associated with that variable.
26772861
26782862=end original
26792863
2680の変数は Perl 5.10 追加されました。
2864C<$`> ($PREMATCH) と同様すが、
2865パターンを実行するときに C</p> 修飾子を使わなければならず、
2866この変数と関連付けられた性能上のペナルティを被りません。
26812867
26822868=begin original
26832869
2684This variable is read-only and dynamically-scoped.
2870See L</Performance issues> above.
26852871
26862872=end original
26872873
2688この変数は読み込み専用で動的スコープ持ちます
2874前述した L</Performance issues> 参照してください
26892875
2876=begin original
2877
2878This variable was added in Perl v5.10.0.
2879
2880=end original
2881
2882この変数は Perl v5.10.0 で追加されました。
2883
2884=begin original
2885
2886This variable is read-only, and its value is dynamically scoped.
2887
2888=end original
2889
2890この変数は読み込み専用で、その値は動的スコープを持ちます。
2891
26902892=item $POSTMATCH
26912893
26922894=item $'
2693X<$'> X<$POSTMATCH> X<${^POSTMATCH}> X<@->
2895X<$'> X<$POSTMATCH> X<@->
26942896
26952897=begin original
26962898
26972899The string following whatever was matched by the last successful
2698pattern match (not counting any matches hidden within a BLOCK or C<eval()>
2900pattern match. (See L</Scoping Rules of Regex Variables>). Example:
2699enclosed by the current BLOCK). Example:
27002901
27012902=end original
27022903
2703最後の成功したパターンマッチ (現在のBLOCK 囲まれ
2904最後の成功したパターンマッチでマッチし部分に続く文字列。
2704BLOCK eval() に隠れている部分でのマッチは勘定に入れない)
2905(L</Scoping Rules of Regex Variables> を参照しください)
2705マッチした部分に続く文字列。
27062906例:
27072907
2708 local $_ = 'abcdefghi';
2908=begin original
2709 /def/;
2710 print "$`:$&:$'\n"; # prints abc:def:ghi
27112909
2910 local $_ = 'abcdefghi';
2911 /def/;
2912 print "$`:$&:$'\n"; # prints abc:def:ghi
2913
2914=end original
2915
2916 local $_ = 'abcdefghi';
2917 /def/;
2918 print "$`:$&:$'\n"; # abc:def:ghi を表示
2919
27122920=begin original
27132921
2714The use of this variable anywhere in a program imposes a considerable
2922See L</Performance issues> above for the serious performance implications
2715performance penalty on all regular expression matches.
2923of using this variable (even once) in your code.
2716To avoid this penalty, you can extract the same substring by
2717using L</@->. Starting with Perl 5.10, you can use the </p> match flag
2718and the C<${^POSTMATCH}> variable to do the same thing for particular
2719match operations.
27202924
27212925=end original
27222926
2723この変数をプログラムのどこかで使うと、プログラム中の正規表現
2927この変数を(一度も)使うによる重大な性能問題についは前述した
2724マッチングにおいてかなりの性能低下引き起こます
2928L</Performance issues> 参照てください
2725このペナルティを避けるために、同じ部分文字列を L</@-> を使って
2726抽出できます。
2727Perl 5.10 から、C</p> マッチングフラグと C<${^POSTMATCH}> 変数を
2728特定のマッチング演算子について同じことをするために使えます。
27292929
27302930=begin original
27312931
2732This variable is read-only and dynamically-scoped.
2932This variable is read-only, and its value is dynamically scoped.
27332933
27342934=end original
27352935
2736この変数は読み込み専用で動的スコープを持ちます。
2936この変数は読み込み専用で、その値は動的スコープを持ちます。
27372937
27382938=begin original
27392939
27402940Mnemonic: C<'> often follows a quoted string.
27412941
27422942=end original
27432943
27442944記憶法: C<'> は多くの場合クォートされた文字列の後にある。
27452945
27462946=item ${^POSTMATCH}
2747X<${^POSTMATCH}> X<$'> X<$POSTMATCH>
2947X<${^POSTMATCH}>
27482948
27492949=begin original
27502950
2751This is similar to C<$'> (C<$POSTMATCH>) except that it does not incur the
2951It is only guaranteed to return a defined value when the pattern was
2752performance penalty associated with that variable, and is only guaranteed
2952compiled or executed with the C</p> modifier.
2753to return a defined value when the pattern was compiled or executed with
2754the C</p> modifier.
27552953
27562954=end original
27572955
2758これは C<$'> (C<$POSTMATCH>) と同様ですが、この変数と関連けられた性能上の
2956パターンが C</p> 修飾子きでコンパイルまたは実行された場合、
2759ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された
2957定義された値が返ることだけが保証されます。
2760場合にのみ定義された値を返すことが保証されます。
27612958
27622959=begin original
27632960
2764This variable was added in Perl 5.10.
2961This is similar to C<$'> (C<$POSTMATCH>) except that to use it you must
2962use the C</p> modifier when executing the pattern, and it does not incur
2963the performance penalty associated with that variable.
27652964
27662965=end original
27672966
2768の変数は Perl 5.10 追加されました。
2967C<$'> (C<$POSTMATCH>) と同様すが、
2968パターンを実行するときに C</p> 修飾子を使わなければならず、
2969この変数と関連付けられた性能上のペナルティを被りません。
27692970
27702971=begin original
27712972
2772This variable is read-only and dynamically-scoped.
2973See L</Performance issues> above.
27732974
27742975=end original
27752976
2776この変数は読み込み専用で動的スコープ持ちます
2977前述した L</Performance issues> 参照してください
27772978
2979=begin original
2980
2981This variable was added in Perl v5.10.0.
2982
2983=end original
2984
2985この変数は Perl v5.10.0 で追加されました。
2986
2987=begin original
2988
2989This variable is read-only, and its value is dynamically scoped.
2990
2991=end original
2992
2993この変数は読み込み専用で、その値は動的スコープを持ちます。
2994
27782995=item $LAST_PAREN_MATCH
27792996
27802997=item $+
27812998X<$+> X<$LAST_PAREN_MATCH>
27822999
27833000=begin original
27843001
2785The text matched by the last bracket of the last successful search pattern.
3002The text matched by the highest used capture group of the last
3003successful search pattern. (See L</Scoping Rules of Regex Variables>).
3004It is logically equivalent to the highest
3005numbered capture variable (C<$1>, C<$2>, ...) which has a defined value.
3006
3007
3008=end original
3009
3010最後に検索されたパターンの最大の使われたの捕捉グループにマッチした文字列。
3011(L</Scoping Rules of Regex Variables> を参照してください)。
3012これは、定義されている最大の番号の捕捉変数
3013(C<$1>, C<$2>, ...) と論理的に等価です。
3014
3015=begin original
3016
27863017This is useful if you don't know which one of a set of alternative patterns
2787matched. For example:
3018matched. For example:
27883019
27893020=end original
27903021
2791最後検索されたパターンの最後の括弧にマッチした文字列
3022わからないような場合使うと便利です
2792これはいくつかの選択肢の中でどれがマッチするのか
3023例えば:
2793わからないような場合に使うと便利です。たとえば:
27943024
2795 /Version: (.*)|Revision: (.*)/ && ($rev = $+);
3025 /Version: (.*)|Revision: (.*)/ && ($rev = $+);
27963026
27973027=begin original
27983028
2799This variable is read-only and dynamically-scoped.
3029This variable is read-only, and its value is dynamically scoped.
28003030
28013031=end original
28023032
2803この変数は読み込み専用で動的スコープを持ちます。
3033この変数は読み込み専用で、その値は動的スコープを持ちます。
28043034
28053035=begin original
28063036
28073037Mnemonic: be positive and forward looking.
28083038
28093039=end original
28103040
28113041記憶法: ポジティブで前向き。
28123042
28133043=item $LAST_SUBMATCH_RESULT
28143044
28153045=item $^N
28163046X<$^N> X<$LAST_SUBMATCH_RESULT>
28173047
28183048=begin original
28193049
28203050The text matched by the used group most-recently closed (i.e. the group
2821with the rightmost closing parenthesis) of the last successful search
3051with the rightmost closing parenthesis) of the last successful match.
2822pattern.
3052(See L</Scoping Rules of Regex Variables>).
28233053
28243054=end original
28253055
2826最近のマッチングに成功した検索パターンのうち、一番最近に閉じられた
3056最近のマッチングに成功した検索パターンのうち、一番最近に閉じられた使われた
2827使われたグループ(つまり、一番右の閉じかっこのグループ)にマッチングした
3057グループ(つまり、一番右の閉じかっこのグループ)にマッチングしたテキスト。
2828テキスト
3058(L</Scoping Rules of Regex Variables> を参照してください)
28293059
28303060=begin original
28313061
3062This is subtly different from C<$+>. For example in
3063
3064=end original
3065
3066これは C<$+> とわずかに異なります。
3067例えば次のものは
3068
3069 "ab" =~ /^((.)(.))$/
3070
3071=begin original
3072
3073we have
3074
3075=end original
3076
3077次の結果になります
3078
3079 $1,$^N have the value "ab"
3080 $2 has the value "a"
3081 $3,$+ have the value "b"
3082
3083=begin original
3084
28323085This is primarily used inside C<(?{...})> blocks for examining text
2833recently matched. For example, to effectively capture text to a variable
3086recently matched. For example, to effectively capture text to a variable
28343087(in addition to C<$1>, C<$2>, etc.), replace C<(...)> with
28353088
28363089=end original
28373090
28383091これは主として最近マッチしたテキストを調べるために C<(?{...})> ブロックの
28393092中で使われます。
28403093例えば、(C<$1>, C<$2> などに加えて) テキストを変数に効率的に捕捉するには、
28413094C<(...)> を以下で置き換えます:
28423095
2843 (?:(...)(?{ $var = $^N }))
3096 (?:(...)(?{ $var = $^N }))
28443097
28453098=begin original
28463099
28473100By setting and then using C<$var> in this way relieves you from having to
28483101worry about exactly which numbered set of parentheses they are.
28493102
28503103=end original
28513104
28523105C<$var> をこの方法で設定してから使うことで、かっこの組の番号について
28533106気にしなくてすむようになります。
28543107
28553108=begin original
28563109
2857This variable was added in Perl 5.8.
3110This variable is read-only, and its value is dynamically scoped.
28583111
28593112=end original
28603113
2861この変数は Perl 5.8 追加されした
3114この変数は読み込み専用、その値は動的スコープを持ち
28623115
28633116=begin original
28643117
3118This variable was added in Perl v5.8.0.
3119
3120=end original
3121
3122この変数は Perl v5.8.0 で追加されました。
3123
3124=begin original
3125
28653126Mnemonic: the (possibly) Nested parenthesis that most recently closed.
28663127
28673128=end original
28683129
28693130記憶法: もっとも最近閉じられた、(おそらく) ネストした (Nested) かっこ。
28703131
28713132=item @LAST_MATCH_END
28723133
28733134=item @+
28743135X<@+> X<@LAST_MATCH_END>
28753136
28763137=begin original
28773138
28783139This array holds the offsets of the ends of the last successful
2879submatches in the currently active dynamic scope. C<$+[0]> is
3140match and any matching capture buffers that the pattern contains.
2880the offset into the string of the end of the entire match. This
3141(See L</Scoping Rules of Regex Variables>)
2881is the same value as what the C<pos> function returns when called
2882on the variable that was matched against. The I<n>th element
2883of this array holds the offset of the I<n>th submatch, so
2884C<$+[1]> is the offset past where C<$1> ends, C<$+[2]> the offset
2885past where C<$2> ends, and so on. You can use C<$#+> to determine
2886how many subgroups were in the last successful match. See the
2887examples given for the C<@-> variable.
28883142
28893143=end original
28903144
2891この配列は、現在アクティブな動的スコープで最後に成功した
3145この配列は、最後に成功したマッチングの末尾へのオフセットと、
2892サブマッチの最後へのオフセを保持します。
3146パターンが含むすべてのマッチング捕捉バファを保持します。
3147(L</Scoping Rules of Regex Variables> を参照してください。)
3148
3149=begin original
3150
3151The number of elements it contains will be one more than the number
3152of capture buffers in the pattern, regardless of which capture buffers
3153actually matched. You can use this to determine how many capture
3154buffers there are in the pattern. (As opposed to C<@-> which may
3155have fewer elements.)
3156
3157=end original
3158
3159含まれる要素の数は、どの捕捉バッファが実際にマッチングしたかに関係なく、
3160パターン内の捕捉バッファの数よりも一つ多くなります。
3161これを使って、パターン内に捕捉バッファがいくつあるかを決定できます。
3162(要素の数が少なくなる C<@-> とは対照的です)。
3163
3164=begin original
3165
3166C<$+[0]> is the offset into the string of the end of the entire match.
3167This is the same value as what the C<pos> function returns when called
3168on the variable that was matched against. The I<n>th element of this
3169array holds the offset of the I<n>th submatch, so C<$+[1]> is the offset
3170past where C<$1> ends, C<$+[2]> the offset past where C<$2> ends, and so
3171on. You can use C<$#+> to determine how many subgroups were in the last
3172successful match. See the examples given for the C<@-> variable.
3173
3174=end original
3175
28933176C<$+[0]> はマッチ全体の文字列の最後へのオフセットです。
2894これはマッチした変数に対して C<pos> 関数を呼び出したときの
3177これはマッチした変数に対して C<pos> 関数を呼び出したときの返り値と同じです。
2895返り値と同じです。
28963178この配列の I<n> 番目の要素は I<n> 番目のサブマッチのオフセットを
2897保持していますので、C<$+[1]> は過去の C<$1> の終わりのオフセット、
3179保持していので、C<$+[1]> は過去の C<$1> の終わりのオフセット、C<$+[2]> は
2898C<$+[2]> は C<$2> のオフセット、という形になります。
3180C<$2> のオフセット、という形になります。
2899C<$#+> は最後に成功したマッチでいくつサブグループがあるかを
3181C<$#+> は最後に成功したマッチでいくつサブグループがあるかを決定するのに
2900決定するのに使えます。
3182使えます。
29013183C<@-> 変数の例を参照して下さい。
29023184
29033185=begin original
29043186
2905This variable was added in Perl 5.6.
3187This variable is read-only, and its value is dynamically scoped.
29063188
29073189=end original
29083190
2909この変数は Perl 5.6 追加されした
3191この変数は読み込み専用、その値は動的スコープを持ち
29103192
3193=begin original
3194
3195This variable was added in Perl v5.6.0.
3196
3197=end original
3198
3199この変数は Perl v5.6.0 で追加されました。
3200
3201=item %{^CAPTURE}
3202
29113203=item %LAST_PAREN_MATCH
29123204
29133205=item %+
2914X<%+> X<%LAST_PAREN_MATCH>
3206X<%+> X<%LAST_PAREN_MATCH> X<%{^CAPTURE}>
29153207
29163208=begin original
29173209
29183210Similar to C<@+>, the C<%+> hash allows access to the named capture
29193211buffers, should they exist, in the last successful match in the
2920currently active dynamic scope.
3212currently active dynamic scope. (See L</Scoping Rules of Regex Variables>).
29213213
29223214=end original
29233215
29243216C<@+> と同様、C<%+> ハッシュは、現在アクティブな動的スコープで最後に成功した
29253217マッチングの名前付き捕捉バッファ(存在すれば)へのアクセスを可能にします。
3218(L</Scoping Rules of Regex Variables> を参照してください)。
29263219
29273220=begin original
29283221
29293222For example, C<$+{foo}> is equivalent to C<$1> after the following match:
29303223
29313224=end original
29323225
29333226例えば、C<$+{foo}> は以下のマッチングの後の C<$1> と等価です:
29343227
2935 'foo' =~ /(?<foo>foo)/;
3228 'foo' =~ /(?<foo>foo)/;
29363229
29373230=begin original
29383231
29393232The keys of the C<%+> hash list only the names of buffers that have
29403233captured (and that are thus associated to defined values).
29413234
29423235=end original
29433236
29443237C<%+> ハッシュのキーは捕捉された(従って定義された値と結びついている)
29453238バッファの名前のみの一覧です。
29463239
29473240=begin original
29483241
3242If multiple distinct capture groups have the same name, then
3243C<$+{NAME}> will refer to the leftmost defined group in the match.
3244
3245=end original
3246
3247同じ名前の複数の異なる補足グループがある場合、
3248C<$+{NAME}> はマッチングの中で一番左側に定義されているグループを
3249参照します。
3250
3251=begin original
3252
29493253The underlying behaviour of C<%+> is provided by the
29503254L<Tie::Hash::NamedCapture> module.
29513255
29523256=end original
29533257
29543258C<%+> の基礎となる振る舞いは L<Tie::Hash::NamedCapture> モジュールで
29553259提供されています。
29563260
29573261=begin original
29583262
29593263B<Note:> C<%-> and C<%+> are tied views into a common internal hash
2960associated with the last successful regular expression. Therefore mixing
3264associated with the last successful regular expression. Therefore mixing
29613265iterative access to them via C<each> may have unpredictable results.
29623266Likewise, if the last successful match changes, then the results may be
29633267surprising.
29643268
29653269=end original
29663270
29673271B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の
29683272内部ハッシュと tie されたビューです。
2969従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果と
3273従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果となります。
2970なります。
29713274同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。
29723275
29733276=begin original
29743277
2975This variable was added in Perl 5.10.
3278This variable was added in Perl v5.10.0. The C<%{^CAPTURE}> alias was
3279added in 5.25.7.
29763280
29773281=end original
29783282
2979この変数は Perl 5.10 で追加されました。
3283この変数は Perl v5.10.0 で追加されました。
3284C<%{^CAPTURE}> の別名は 5.25.7 で追加されました。
29803285
29813286=begin original
29823287
2983This variable is read-only and dynamically-scoped.
3288This variable is read-only, and its value is dynamically scoped.
29843289
29853290=end original
29863291
2987この変数は読み込み専用で動的スコープを持ちます。
3292この変数は読み込み専用で、その値は動的スコープを持ちます。
29883293
29893294=item @LAST_MATCH_START
29903295
29913296=item @-
29923297X<@-> X<@LAST_MATCH_START>
29933298
29943299=begin original
29953300
3301This array holds the offsets of the beginnings of the last successful
3302match and any capture buffers it contains.
3303(See L</Scoping Rules of Regex Variables>).
3304
3305=end original
3306
3307この配列は、最後に成功したマッチングの先頭へのオフセットと、
3308パターンが含むすべてのマッチング捕捉バッファを保持します。
3309(L</Scoping Rules of Regex Variables> を参照してください。)
3310
3311=begin original
3312
3313The number of elements it contains will be one more than the number of
3314the highest capture buffers (also called a subgroup) that actually
3315matched something. (As opposed to C<@+> which may have more elements.)
3316
3317=end original
3318
3319含まれる要素の数は、実際に何かにマッチングした最も高い捕捉バッファ
3320(サブグループとも呼ばれる)の数よりも一つ多くなります
3321(要素の数が多くなる C<@+> とは対照的です)。
3322
3323=begin original
3324
29963325C<$-[0]> is the offset of the start of the last successful match.
2997C<$-[>I<n>C<]> is the offset of the start of the substring matched by
3326C<$-[I<n>]> is the offset of the start of the substring matched by
29983327I<n>-th subpattern, or undef if the subpattern did not match.
29993328
30003329=end original
30013330
30023331C<$-[0]> は最後に成功したマッチの先頭のオフセットです。
3003C<$-[>I<n>C<]> は I<n> 番目のサブパターンにマッチした部分文字列の
3332C<$-[I<n>]> は I<n> 番目のサブパターンにマッチした部分文字列の先頭
3004先頭のオフセットですサブパターンがマッチしなかった場合は undef です。
3333オフセットです; サブパターンがマッチしなかった場合は undef です。
30053334
30063335=begin original
30073336
3008Thus, after a match against C<$_>, C<$&> coincides with C<substr $_, $-[0],
3337Thus, after a match against C<$_>, C<$&> coincides with
3009$+[0] - $-[0]>. Similarly, $I<n> coincides with C<substr $_, $-[n],
3338C<substr $_, $-[0], $+[0] - $-[0]>. Similarly, C<$I<n>> coincides
3010$+[n] - $-[n]> if C<$-[n]> is defined, and $+ coincides with
3339with C<substr $_, $-[n], $+[n] - $-[n]> if C<$-[n]> is defined, and
3011C<substr $_, $-[$#-], $+[$#-] - $-[$#-]>. One can use C<$#-> to find the last
3340C<$+> coincides with C<substr $_, $-[$#-], $+[$#-] - $-[$#-]>.
3012matched subgroup in the last successful match. Contrast with
3341One can use C<$#-> to find the last matched subgroup in the last
3013C<$#+>, the number of subgroups in the regular expression. Compare
3342successful match. Contrast with C<$#+>, the number of subgroups
3014with C<@+>.
3343in the regular expression.
30153344
30163345=end original
30173346
3018従って C<$_> のマッチの後、C<$&> は C<substr $_, $-[0], $+[0] - $-[0]>
3347従って C<$_> のマッチの後、C<$I<n>>
3019一致します。
3348C<substr $_, $-[0], $+[0] - $-[0]> と一致します。
30203349同様に、$I<n> は、C<$-[n]> が定義されていれば
30213350C<substr $_, $-[n], $+[n] - $-[n]> と一致し、
3022$+ は C<substr $_, $-[$#-], $+[$#-] - $-[$#-]> と一致します。
3351C<$+> は C<substr $_, $-[$#-], $+[$#-] - $-[$#-]> と一致します。
30233352C<$#-> は直前に成功したマッチで最後のマッチしたサブグループを
30243353探すのに使えます。
30253354正規表現でのサブグループの数である C<$#+> と対照的です。
3026C<@+> と比較してください。
30273355
30283356=begin original
30293357
3030This array holds the offsets of the beginnings of the last
3031successful submatches in the currently active dynamic scope.
30323358C<$-[0]> is the offset into the string of the beginning of the
3033entire match. The I<n>th element of this array holds the offset
3359entire match. The I<n>th element of this array holds the offset
30343360of the I<n>th submatch, so C<$-[1]> is the offset where C<$1>
30353361begins, C<$-[2]> the offset where C<$2> begins, and so on.
30363362
30373363=end original
30383364
3039この配列は現在アクティブな動的スコープ内で最後に成功した
3040サブマッチの先頭位置のオフセットを保持します。
30413365C<$-[0]> はマッチ全体の先頭の文字列へのオフセットです。
30423366この配列の I<n> 番目の要素は I<n> 番目のサブマッチへの
30433367オフセットを保持しますので、C<$-[1]> は C<$1> の先頭への
30443368オフセット、C<$-[2]> は C<$2> の先頭へのオフセット、などとなります。
30453369
30463370=begin original
30473371
30483372After a match against some variable C<$var>:
30493373
30503374=end original
30513375
30523376ある変数 C<$var> でマッチした後、以下のようになります。
30533377
30543378=over 5
30553379
30563380=item C<$`> is the same as C<substr($var, 0, $-[0])>
30573381
3058(C<$`> は C<substr($var, 0, $-[0])> と同じです)
3382(C<$`> は C<substr($var, 0, $-[0])> と同じです)
30593383
30603384=item C<$&> is the same as C<substr($var, $-[0], $+[0] - $-[0])>
30613385
3062(C<$&> は C<substr($var, $-[0], $+[0] - $-[0])> と同じです)
3386(C<$&> は C<substr($var, $-[0], $+[0] - $-[0])> と同じです)
30633387
30643388=item C<$'> is the same as C<substr($var, $+[0])>
30653389
3066(C<$'> は C<substr($var, $+[0])> と同じです)
3390(C<$'> は C<substr($var, $+[0])> と同じです)
30673391
30683392=item C<$1> is the same as C<substr($var, $-[1], $+[1] - $-[1])>
30693393
3070(C<$1> は C<substr($var, $-[1], $+[1] - $-[1])> と同じです)
3394(C<$1> は C<substr($var, $-[1], $+[1] - $-[1])> と同じです)
30713395
30723396=item C<$2> is the same as C<substr($var, $-[2], $+[2] - $-[2])>
30733397
3074(C<$2> は C<substr($var, $-[2], $+[2] - $-[2])> と同じです)
3398(C<$2> は C<substr($var, $-[2], $+[2] - $-[2])> と同じです)
30753399
30763400=item C<$3> is the same as C<substr($var, $-[3], $+[3] - $-[3])>
30773401
3078(C<$3> は C<substr $var, $-[3], $+[3] - $-[3])> と同じです)
3402(C<$3> は C<substr $var, $-[3], $+[3] - $-[3])> と同じです)
30793403
30803404=back
30813405
30823406=begin original
30833407
3084This variable was added in Perl 5.6.
3408This variable is read-only, and its value is dynamically scoped.
30853409
30863410=end original
30873411
3088この変数は Perl 5.6 追加されした
3412この変数は読み込み専用、その値は動的スコープを持ち
30893413
3090=item %LAST_MATCH_START
3414=begin original
30913415
3416This variable was added in Perl v5.6.0.
3417
3418=end original
3419
3420この変数は Perl v5.6.0 で追加されました。
3421
3422=item %{^CAPTURE_ALL}
3423X<%{^CAPTURE_ALL}>
3424
30923425=item %-
3093X<%-> X<%LAST_MATCH_START>
3426X<%->
30943427
30953428=begin original
30963429
3097Similar to C<%+>, this variable allows access to the named capture groups
3430Similar to C<%+>, this variable allows access to the named capture
3098in the last successful match in the currently active dynamic scope. To
3431groups in the last successful match in the currently active dynamic
3099each capture group name found in the regular expression, it associates a
3432scope. (See L</Scoping Rules of Regex Variables>). To each capture group
3100reference to an array containing the list of values captured by all
3433name found in the regular expression, it associates a reference to an
3101buffers with that name (should there be several of them), in the order
3434array containing the list of values captured by all buffers with that
3102where they appear.
3435name (should there be several of them), in the order where they appear.
31033436
31043437=end original
31053438
31063439C<%+> と同様、この変数は現在アクティブな動的スコープで最後に成功した
31073440マッチングの名前付き捕捉グループへのアクセスを可能にします。
3441(L</Scoping Rules of Regex Variables> を参照してください)。
31083442正規表現中に捕捉グループ名が現れるごとに、その名前のグループ全てで
31093443(複数あるでしょう)捕捉されている値のリストを出現順で含む配列への
31103444リファレンスと関連付けられます。
31113445
31123446=begin original
31133447
31143448Here's an example:
31153449
31163450=end original
31173451
3118以下を示します:
3452以下す:
31193453
31203454 if ('1234' =~ /(?<A>1)(?<B>2)(?<A>3)(?<B>4)/) {
31213455 foreach my $bufname (sort keys %-) {
31223456 my $ary = $-{$bufname};
31233457 foreach my $idx (0..$#$ary) {
31243458 print "\$-{$bufname}[$idx] : ",
3125 (defined($ary->[$idx]) ? "'$ary->[$idx]'" : "undef"),
3459 (defined($ary->[$idx])
3460 ? "'$ary->[$idx]'"
3461 : "undef"),
31263462 "\n";
31273463 }
31283464 }
31293465 }
31303466
31313467=begin original
31323468
31333469would print out:
31343470
31353471=end original
31363472
31373473とすると、以下のものが表示されます:
31383474
3139 $-{A}[0] : '1'
3475 $-{A}[0] : '1'
3140 $-{A}[1] : '3'
3476 $-{A}[1] : '3'
3141 $-{B}[0] : '2'
3477 $-{B}[0] : '2'
3142 $-{B}[1] : '4'
3478 $-{B}[1] : '4'
31433479
31443480=begin original
31453481
31463482The keys of the C<%-> hash correspond to all buffer names found in
31473483the regular expression.
31483484
31493485=end original
31503486
31513487C<%-> ハッシュのキーは正規表現で見つかった全てのバッファ名に対応します。
31523488
31533489=begin original
31543490
31553491The behaviour of C<%-> is implemented via the
31563492L<Tie::Hash::NamedCapture> module.
31573493
31583494=end original
31593495
31603496C<%-> の振る舞いは L<Tie::Hash::NamedCapture> モジュールを使って
31613497実装されています。
31623498
31633499=begin original
31643500
31653501B<Note:> C<%-> and C<%+> are tied views into a common internal hash
3166associated with the last successful regular expression. Therefore mixing
3502associated with the last successful regular expression. Therefore mixing
31673503iterative access to them via C<each> may have unpredictable results.
31683504Likewise, if the last successful match changes, then the results may be
3169surprising.
3505surprising. See L</Scoping Rules of Regex Variables>.
31703506
31713507=end original
31723508
31733509B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の
31743510内部ハッシュと tie されたビューです。
3175従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果と
3511従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果となります。
3176なります。
31773512同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。
3513L</Scoping Rules of Regex Variables> を参照してください。
31783514
31793515=begin original
31803516
3181This variable was added in Perl 5.10
3517This variable was added in Perl v5.10.0. The C<%{^CAPTURE_ALL}> alias was
3518added in 5.25.7.
31823519
31833520=end original
31843521
3185この変数は Perl 5.10 で追加されました。
3522この変数は Perl v5.10.0 で追加されました。
3523C<%{^CAPTURE_ALL}> の別名は 5.25.7 で追加されました。
31863524
31873525=begin original
31883526
3189This variable is read-only and dynamically-scoped.
3527This variable is read-only, and its value is dynamically scoped.
31903528
31913529=end original
31923530
3193この変数は読み込み専用で動的スコープを持ちます。
3531この変数は読み込み専用で、その値は動的スコープを持ちます。
31943532
3533=item ${^LAST_SUCCESSFUL_PATTERN}
3534
3535=begin original
3536
3537The last successful pattern that matched in the current scope. The empty
3538pattern defaults to matching to this. For instance:
3539
3540=end original
3541
3542現在のスコープでマッチングした、最後に成功したパターン。
3543からパターンはこれにマッチングします。
3544例えば:
3545
3546 if (m/foo/ || m/bar/) {
3547 s//BLAH/;
3548 }
3549
3550=begin original
3551
3552and
3553
3554=end original
3555
3556および
3557
3558 if (m/foo/ || m/bar/) {
3559 s/${^LAST_SUCCESSFUL_PATTERN}/BLAH/;
3560 }
3561
3562=begin original
3563
3564are equivalent.
3565
3566=end original
3567
3568は等価です。
3569
3570=begin original
3571
3572You can use this to debug which pattern matched last, or to match with it again.
3573
3574=end original
3575
3576どのパターンが最後にマッチングしたかをデバッグしたり、
3577再び同じものでマッチングするためにこれを使えます。
3578
3579=begin original
3580
3581Added in Perl 5.37.10.
3582
3583=end original
3584
3585Perl 5.37.10 で追加されました。
3586
31953587=item $LAST_REGEXP_CODE_RESULT
31963588
31973589=item $^R
31983590X<$^R> X<$LAST_REGEXP_CODE_RESULT>
31993591
32003592=begin original
32013593
32023594The result of evaluation of the last successful C<(?{ code })>
3203regular expression assertion (see L<perlre>). May be written to.
3595regular expression assertion (see L<perlre>).
32043596
32053597=end original
32063598
32073599最後に成功した C<(?{ code })> 正規表現アサートの評価の結果です
3208(L<perlre> を参照して下さい)。おそらくもっと書き足します。
3600(L<perlre> を参照して下さい)。
32093601
32103602=begin original
32113603
3604This variable may be written to, and its value is scoped normally,
3605unlike most other regex variables.
3606
3607=end original
3608
3609この変数は、その他のほとんどの正規表現変数と異なり、
3610書き込み可能で、その値は通常のスコープを持ちます。
3611
3612=begin original
3613
32123614This variable was added in Perl 5.005.
32133615
32143616=end original
32153617
32163618この変数は Perl 5.005 で追加されました。
32173619
3620=item ${^RE_COMPILE_RECURSION_LIMIT}
3621X<${^RE_COMPILE_RECURSION_LIMIT}>
3622
3623=begin original
3624
3625The current value giving the maximum number of open but unclosed
3626parenthetical groups there may be at any point during a regular
3627expression compilation. The default is currently 1000 nested groups.
3628You may adjust it depending on your needs and the amount of memory
3629available.
3630
3631=end original
3632
3633正規表現コンパイル中の任意の時点での開いているけれども閉じていない
3634かっこグループの最大値として与えられている現在の値。
3635デフォルトは現在の所 1000 ネストグループです。
3636これは必要性と利用可能なメモリ量に合わせて調整できます。
3637
3638=begin original
3639
3640This variable was added in Perl v5.30.0.
3641
3642=end original
3643
3644この変数は Perl v5.30.0 で追加されました。
3645
32183646=item ${^RE_DEBUG_FLAGS}
32193647X<${^RE_DEBUG_FLAGS}>
32203648
32213649=begin original
32223650
3223The current value of the regex debugging flags. Set to 0 for no debug output
3651The current value of the regex debugging flags. Set to 0 for no debug output
3224even when the C<re 'debug'> module is loaded. See L<re> for details.
3652even when the C<re 'debug'> module is loaded. See L<re> for details.
32253653
32263654=end original
32273655
32283656正規表現デバッグフラグの現在の値です。
32290 をセットすると、C<re 'debug'> モジュールが読み込まれていても
36570 をセットすると、C<re 'debug'> モジュールが読み込まれていてもデバッグ出力を
3230デバッグ出力を行いません。
3658行いません。
32313659詳細については L<re> を参照してください。
32323660
32333661=begin original
32343662
3235This variable was added in Perl 5.10.
3663This variable was added in Perl v5.10.0.
32363664
32373665=end original
32383666
3239この変数は Perl 5.10 で追加されました。
3667この変数は Perl v5.10.0 で追加されました。
32403668
32413669=item ${^RE_TRIE_MAXBUF}
32423670X<${^RE_TRIE_MAXBUF}>
32433671
32443672=begin original
32453673
32463674Controls how certain regex optimisations are applied and how much memory they
3247utilize. This value by default is 65536 which corresponds to a 512kB temporary
3675utilize. This value by default is 65536 which corresponds to a 512kB
3248cache. Set this to a higher value to trade memory for speed when matching
3676temporary cache. Set this to a higher value to trade
3249large alternations. Set it to a lower value if you want the optimisations to
3677memory for speed when matching large alternations. Set
3678it to a lower value if you want the optimisations to
32503679be as conservative of memory as possible but still occur, and set it to a
32513680negative value to prevent the optimisation and conserve the most memory.
32523681Under normal situations this variable should be of no interest to you.
32533682
32543683=end original
32553684
3256どれくらい正規表現の最適化を行い、どれくらいのメモリを利用するかを
3685どれくらい正規表現の最適化を行い、どれくらいのメモリを利用するかを制御します。
3257制御します。
32583686デフォルトではこの値は 65536 で、512kB の一時キャッシュに相当します。
3259この値を大きくすると、大きなものとマッチングするときに速度を重視して
3687この値を大きくすると、大きなものとマッチングするときに速度を重視して多くの
3260多くのメモリを使います。
3688メモリを使います。
32613689もしできるだけ保守的なメモリ消費をするけれども使うこともある、というように
32623690最適化したい場合は小さい値を設定します; 負の値を設定すると最適化は行わず、
32633691最大限メモリを節約します。
32643692通常の状況では、この変数はあなたの興味を引くものではないでしょう。
32653693
32663694=begin original
32673695
3268This variable was added in Perl 5.10.
3696This variable was added in Perl v5.10.0.
32693697
32703698=end original
32713699
3272この変数は Perl 5.10 で追加されました。
3700この変数は Perl v5.10.0 で追加されました。
32733701
32743702=back
32753703
32763704=head2 Variables related to filehandles
32773705
32783706(ファイルハンドル関連の変数)
32793707
32803708=begin original
32813709
32823710Variables that depend on the currently selected filehandle may be set
32833711by calling an appropriate object method on the C<IO::Handle> object,
32843712although this is less efficient than using the regular built-in
3285variables. (Summary lines below for this contain the word HANDLE.)
3713variables. (Summary lines below for this contain the word HANDLE.)
32863714First you must say
32873715
32883716=end original
32893717
32903718現在選択されているファイルハンドルに依存する変数の場合には、代わりに
32913719C<IO::Handle> オブジェクトに関するオブジェクトメソッドを呼び出して
3292設定することができますが、通常の組み込み変数よりは効率が落ちます。
3720設定できますが、通常の組み込み変数よりは効率が落ちます。
32933721(以下の要約では HANDLE という語を含んでいます。)
32943722まず最初に必ず、
32953723
3296 use IO::Handle;
3724 use IO::Handle;
32973725
32983726=begin original
32993727
33003728after which you may use either
33013729
33023730=end original
33033731
33043732と書き、その後で以下のように書くか、
33053733
3306 method HANDLE EXPR
3734 method HANDLE EXPR
33073735
33083736=begin original
33093737
33103738or more safely,
33113739
33123740=end original
33133741
33143742もしくはより安全に以下のように書きます:
33153743
3316 HANDLE->method(EXPR)
3744 HANDLE->method(EXPR)
33173745
33183746=begin original
33193747
3320Each method returns the old value of the C<IO::Handle> attribute. The
3748Each method returns the old value of the C<IO::Handle> attribute. The
33213749methods each take an optional EXPR, which, if supplied, specifies the
3322new value for the C<IO::Handle> attribute in question. If not
3750new value for the C<IO::Handle> attribute in question. If not
33233751supplied, most methods do nothing to the current value--except for
33243752C<autoflush()>, which will assume a 1 for you, just to be different.
33253753
33263754=end original
33273755
33283756それぞれのメソッドは、C<IO::Handle> 属性の昔の値を返します。
3329メソッドはそれぞれ EXPR をとることができ、指定した場合には、
3757メソッドはそれぞれ EXPR をとることができ、指定した場合には、問題の
3330問題の C<IO::Handle> 属性の新しい値を指定することになります。
3758C<IO::Handle> 属性の新しい値を指定することになります。
33313759指定しない場合には、多くのメソッドでは現在の値に対して何もしませんが、
33323760C<autoflush()> では 1 を指定されたものとします。
33333761
33343762=begin original
33353763
33363764Because loading in the C<IO::Handle> class is an expensive operation,
33373765you should learn how to use the regular built-in variables.
33383766
33393767=end original
33403768
33413769C<IO::Handle> クラスを読み込むのはコストの高い操作なので、
33423770通常の組み込み変数の使い方を覚えるべきです。
33433771
33443772=begin original
33453773
3346A few of these variables are considered "read-only". This means that
3774A few of these variables are considered "read-only". This means that
33473775if you try to assign to this variable, either directly or indirectly
33483776through a reference, you'll raise a run-time exception.
33493777
33503778=end original
33513779
33523780これらの変数のいくつかは「読み込み専用」と考えられます。
33533781つまり、もしこの変数に対して直接またはリファレンスを通して間接に
33543782代入しようとすると、、実行時エラーが発生します。
33553783
33563784=begin original
33573785
33583786You should be very careful when modifying the default values of most
3359special variables described in this document. In most cases you want
3787special variables described in this document. In most cases you want
33603788to localize these variables before changing them, since if you don't,
33613789the change may affect other modules which rely on the default values
3362of the special variables that you have changed. This is one of the
3790of the special variables that you have changed. This is one of the
33633791correct ways to read the whole file at once:
33643792
33653793=end original
33663794
33673795この文書に記述されているほとんどの特殊変数のデフォルト値を変更するときには
33683796とても慎重になるべきです。
33693797ほとんどの場合、これらの変数を変更する前にこれらをローカル化したいでしょう;
33703798さもなければ、あなたが変更した特殊変数のデフォルト値に依存している
33713799その他のモジュールにも影響を与えるかもしれないからです。
33723800これはファイル全体を一度に読み込む正しい方法の一つです:
33733801
3374 open my $fh, "<", "foo" or die $!;
3802=begin original
3375 local $/; # enable localized slurp mode
3376 my $content = <$fh>;
3377 close $fh;
33783803
3804 open my $fh, "<", "foo" or die $!;
3805 local $/; # enable localized slurp mode
3806 my $content = <$fh>;
3807 close $fh;
3808
3809=end original
3810
3811 open my $fh, "<", "foo" or die $!;
3812 local $/; # ローカル化された吸い込みモードを有効にする
3813 my $content = <$fh>;
3814 close $fh;
3815
33793816=begin original
33803817
33813818But the following code is quite bad:
33823819
33833820=end original
33843821
33853822しかし以下のコードは完全に悪いものです:
33863823
3387 open my $fh, "<", "foo" or die $!;
3824=begin original
3388 undef $/; # enable slurp mode
3389 my $content = <$fh>;
3390 close $fh;
33913825
3826 open my $fh, "<", "foo" or die $!;
3827 undef $/; # enable slurp mode
3828 my $content = <$fh>;
3829 close $fh;
3830
3831=end original
3832
3833 open my $fh, "<", "foo" or die $!;
3834 undef $/; # 吸い込みモードを有効にする
3835 my $content = <$fh>;
3836 close $fh;
3837
33923838=begin original
33933839
33943840since some other module, may want to read data from some file in the
33953841default "line mode", so if the code we have just presented has been
33963842executed, the global value of C<$/> is now changed for any other code
33973843running inside the same Perl interpreter.
33983844
33993845=end original
34003846
34013847なぜなら、その他のモジュールでは、デフォルトの「行モード」でファイルを
34023848読もうとするかも知れませんが、もし単に前述のコードを実行すると、
34033849C<$/> のグローバルな値が、同じ Perl インタプリタ内で実行される
34043850その他のコードに対しても変更されるからです。
34053851
34063852=begin original
34073853
34083854Usually when a variable is localized you want to make sure that this
3409change affects the shortest scope possible. So unless you are already
3855change affects the shortest scope possible. So unless you are already
3410inside some short C<{}> block, you should create one yourself. For
3856inside some short C<{}> block, you should create one yourself. For
34113857example:
34123858
34133859=end original
34143860
34153861通常、変数をローカル化するとき、この変更ができるだけ最短のスコープに
34163862影響を与えることを確実にしたいでしょう。
34173863従って、既に小さい C<{}> ブロックの内側であるのでない限り、それを
34183864自身で作るべきです。
34193865例えば:
34203866
3421 my $content = '';
3867 my $content = '';
3422 open my $fh, "<", "foo" or die $!;
3868 open my $fh, "<", "foo" or die $!;
3423 {
3869 {
3424 local $/;
3870 local $/;
3425 $content = <$fh>;
3871 $content = <$fh>;
3426 }
3872 }
3427 close $fh;
3873 close $fh;
34283874
34293875=begin original
34303876
34313877Here is an example of how your own code can go broken:
34323878
34333879=end original
34343880
34353881以下はどのように自分のコードが壊れるかの例です:
34363882
3437 for ( 1..3 ){
3883 for ( 1..3 ){
3438 $\ = "\r\n";
3884 $\ = "\r\n";
3439 nasty_break();
3885 nasty_break();
3440 print "$_";
3886 print "$_";
3441 }
3887 }
34423888
3443 sub nasty_break {
3889=begin original
3444 $\ = "\f";
3445 # do something with $_
3446 }
34473890
3891 sub nasty_break {
3892 $\ = "\f";
3893 # do something with $_
3894 }
3895
3896=end original
3897
3898 sub nasty_break {
3899 $\ = "\f";
3900 # $_ で何かする
3901 }
3902
34483903=begin original
34493904
34503905You probably expect this code to print the equivalent of
34513906
34523907=end original
34533908
34543909おそらくこのコードは以下のように表示されることを期待しています:
34553910
34563911 "1\r\n2\r\n3\r\n"
34573912
34583913=begin original
34593914
34603915but instead you get:
34613916
34623917=end original
34633918
34643919しかし、以下のようになります:
34653920
34663921 "1\f2\f3\f"
34673922
34683923=begin original
34693924
34703925Why? Because C<nasty_break()> modifies C<$\> without localizing it
3471first. The value you set in C<nasty_break()> is still there when you
3926first. The value you set in C<nasty_break()> is still there when you
3472return. The fix is to add C<local()> so the value doesn't leak out of
3927return. The fix is to add C<local()> so the value doesn't leak out of
34733928C<nasty_break()>:
34743929
34753930=end original
34763931
34773932なぜでしょう?
34783933C<nasty_break()> は C<$_> をローカル化する前に変更するからです。
34793934C<nasty_break()> で設定した値は戻ったときにまだそこにあります。
34803935修正するには、C<local()> を追加して、値が C<nasty_break()> の外に
34813936漏れないようにします:
34823937
3483 local $\ = "\f";
3938 local $\ = "\f";
34843939
34853940=begin original
34863941
34873942It's easy to notice the problem in such a short example, but in more
34883943complicated code you are looking for trouble if you don't localize
34893944changes to the special variables.
34903945
34913946=end original
34923947
34933948このような短い例では問題に気付くのは簡単ですが、より複雑なコードでは、
34943949もし特殊変数の変更をローカル化していないと問題を探すことになります。
34953950
34963951=over 8
34973952
34983953=item $ARGV
34993954X<$ARGV>
35003955
35013956=begin original
35023957
3503Contains the name of the current file when reading from C<< <> >> .
3958Contains the name of the current file when reading from C<< <> >>.
35043959
35053960=end original
35063961
35073962C<< <> >> から読込みを行なっているとき、その時点のファイル名を示します。
35083963
35093964=item @ARGV
35103965X<@ARGV>
35113966
35123967=begin original
35133968
35143969The array C<@ARGV> contains the command-line arguments intended for
3515the script. C<$#ARGV> is generally the number of arguments minus
3970the script. C<$#ARGV> is generally the number of arguments minus
35163971one, because C<$ARGV[0]> is the first argument, I<not> the program's
3517command name itself. See C<$0> for the command name.
3972command name itself. See L</$0> for the command name.
35183973
35193974=end original
35203975
35213976配列 C<@ARGV> は、コマンドラインからスクリプトに渡す引数が入れられます。
35223977C<$ARGV[0]> がI<プログラムのコマンド名自身ではなく>、
35233978最初の引数ですから、C<$#ARGV> は一般には、引数の個数 - 1 となります。
3524コマンド名については、C<$0> を参照してください。
3979コマンド名については、L</$0> を参照してください。
35253980
35263981=item ARGV
35273982X<ARGV>
35283983
35293984=begin original
35303985
35313986The special filehandle that iterates over command-line filenames in
3532C<@ARGV>. Usually written as the null filehandle in the angle operator
3987C<@ARGV>. Usually written as the null filehandle in the angle operator
3533C<< <> >>. Note that currently C<ARGV> only has its magical effect
3988C<< <> >>. Note that currently C<ARGV> only has its magical effect
35343989within the C<< <> >> operator; elsewhere it is just a plain filehandle
3535corresponding to the last file opened by C<< <> >>. In particular,
3990corresponding to the last file opened by C<< <> >>. In particular,
35363991passing C<\*ARGV> as a parameter to a function that expects a filehandle
35373992may not cause your function to automatically read the contents of all the
35383993files in C<@ARGV>.
35393994
35403995=end original
35413996
35423997C<@ARGV> にあるコマンドラインで指定されたファイル名に対して反復する
35433998特殊ファイルハンドルです。
35443999通常角かっこ C<< <> >> の中で空ファイルハンドルとして書かれます。
35454000現在のところ、C<ARGV> は C<< <> >> 演算子の中でのみ特別な効果があることに
35464001注意してください; その他の場所では、C<< <> >> で開かれた最後のファイルに
35474002対応する普通のファイルハンドルです。
35484003特に、ファイルハンドルを想定している関数に C<\*ARGV> を引数として渡しても、
35494004関数内で C<@ARGV> にある全てのファイルの内容を自動的に読み込むことには
35504005なりません。
35514006
35524007=item ARGVOUT
35534008X<ARGVOUT>
35544009
35554010=begin original
35564011
35574012The special filehandle that points to the currently open output file
3558when doing edit-in-place processing with B<-i>. Useful when you have
4013when doing edit-in-place processing with B<-i>. Useful when you have
3559to do a lot of inserting and don't want to keep modifying C<$_>. See
4014to do a lot of inserting and don't want to keep modifying C<$_>. See
3560L<perlrun> for the B<-i> switch.
4015L<perlrun|perlrun/-i[extension]> for the B<-i> switch.
35614016
35624017=end original
35634018
35644019B<-i> を使ってその場修正を行っているときに、現在開いている出力ファイルを
35654020示す特殊ファイルハンドルです。
3566たくさんの挿入をする必要があるときに C<$_> を修正し続けたくない場合に
4021たくさんの挿入をする必要があるときに C<$_> を修正し続けたくない場合に有用です。
3567有用です。
4022B<-i> オプションについては L<perlrun|perlrun/-i[extension]> を
3568B<-i> オプションについては L<perlrun> を参照してください。
4023参照してください。
35694024
3570=item Handle->output_field_separator( EXPR )
4025=item IO::Handle->output_field_separator( EXPR )
35714026
35724027=item $OUTPUT_FIELD_SEPARATOR
35734028
35744029=item $OFS
35754030
35764031=item $,
35774032X<$,> X<$OFS> X<$OUTPUT_FIELD_SEPARATOR>
35784033
35794034=begin original
35804035
3581The output field separator for the print operator. If defined, this
4036The output field separator for the print operator. If defined, this
3582value is printed between each of print's arguments. Default is C<undef>.
4037value is printed between each of print's arguments. Default is C<undef>.
35834038
35844039=end original
35854040
35864041print 演算子のための出力フィールドセパレータ。
35874042定義されると、この値がそれぞれの print の引数の間に表示されます。
35884043デフォルトは C<undef> です。
35894044
35904045=begin original
35914046
4047You cannot call C<output_field_separator()> on a handle, only as a
4048static method. See L<IO::Handle|IO::Handle>.
4049
4050=end original
4051
4052ハンドルに対して C<output_field_separator()> を呼び出すことはできません;
4053静的メソッドしてのみです。
4054L<IO::Handle|IO::Handle> を参照してください。
4055
4056=begin original
4057
35924058Mnemonic: what is printed when there is a "," in your print statement.
35934059
35944060=end original
35954061
35964062記憶法: print 文で "," を書いた場所に印字されるもの。
35974063
35984064=item HANDLE->input_line_number( EXPR )
35994065
36004066=item $INPUT_LINE_NUMBER
36014067
36024068=item $NR
36034069
36044070=item $.
36054071X<$.> X<$NR> X<$INPUT_LINE_NUMBER> X<line number>
36064072
36074073=begin original
36084074
36094075Current line number for the last filehandle accessed.
36104076
36114077=end original
36124078
36134079最後にアクセスされたファイルハンドルの現在の行番号。
36144080
36154081=begin original
36164082
36174083Each filehandle in Perl counts the number of lines that have been read
3618from it. (Depending on the value of C<$/>, Perl's idea of what
4084from it. (Depending on the value of C<$/>, Perl's idea of what
36194085constitutes a line may not match yours.) When a line is read from a
36204086filehandle (via C<readline()> or C<< <> >>), or when C<tell()> or
36214087C<seek()> is called on it, C<$.> becomes an alias to the line counter
36224088for that filehandle.
36234089
36244090=end original
36254091
36264092Perl の各ファイルハンドルは、そこから読み込んだ行数を数えています。
36274093(C<$/> の値に依存して、何が行を構成するかに関する Perl の考えはあなたの
36284094考えと一致しないかもしれません。)
36294095行が(C<readline()> や C<< <> >> を使って)ファイルハンドルから読み込まれたか、
36304096C<tell()> や C<seek()> がファイルハンドルに対して呼び出された場合、
36314097C<$.> はそのファイルハンドルの行カウンタへのエイリアスとなります。
36324098
36334099=begin original
36344100
36354101You can adjust the counter by assigning to C<$.>, but this will not
3636actually move the seek pointer. I<Localizing C<$.> will not localize
4102actually move the seek pointer. I<Localizing C<$.> will not localize
3637the filehandle's line count>. Instead, it will localize perl's notion
4103the filehandle's line count>. Instead, it will localize perl's notion
36384104of which filehandle C<$.> is currently aliased to.
36394105
36404106=end original
36414107
36424108C<$.> へ代入することでカウンタの値を修正できますが、これは実際にシーク
36434109ポインタを動かすことはありません。
3644I<C<$.> をローカル化してもファイルハンドルの行カウンタは
4110I<C<$.> をローカル化してもファイルハンドルの行カウンタはローカル化されません>。
3645ローカル化されません>。
36464111代わりに、現在 C<$.> がどのファイルハンドルへのエイリアスかという情報が
36474112ローカル化されます。
36484113
36494114=begin original
36504115
36514116C<$.> is reset when the filehandle is closed, but B<not> when an open
3652filehandle is reopened without an intervening C<close()>. For more
4117filehandle is reopened without an intervening C<close()>. For more
3653details, see L<perlop/"IE<sol>O Operators">. Because C<< <> >> never does
4118details, see L<perlop/"IE<sol>O Operators">. Because C<< <> >> never does
36544119an explicit close, line numbers increase across C<ARGV> files (but see
36554120examples in L<perlfunc/eof>).
36564121
36574122=end original
36584123
36594124C<$.> はファイルハンドルがクローズされるとリセットされますが、
36604125オープンしているファイルハンドルが C<close()> されることなく再オープンされた
36614126場合にはリセット B<されません>。
36624127さらなる詳細については、L<perlop/"IE<sol>O Operators"> を参照してください。
36634128なぜなら、 C<< <> >> は決して明示的なクローズは行わず、行番号は C<ARGV> の
36644129ファイル間で通算してカウントされるからです(但し L<perlfunc/eof> の例を
36654130参照してください)。
36664131
36674132=begin original
36684133
36694134You can also use C<< HANDLE->input_line_number(EXPR) >> to access the
36704135line counter for a given filehandle without having to worry about
36714136which handle you last accessed.
36724137
36734138=end original
36744139
36754140また、C<< HANDLE->input_line_number(EXPR) >> とすることで、どのハンドルに
36764141最後にアクセスしたかを気にすることなく行カウンタにアクセスできます。
36774142
36784143=begin original
36794144
36804145Mnemonic: many programs use "." to mean the current line number.
36814146
36824147=end original
36834148
36844149記憶法: 多くのプログラムで "." が現在行番号を示すように使われています。
36854150
3686=item HANDLE->input_record_separator( EXPR )
4151=item IO::Handle->input_record_separator( EXPR )
36874152
36884153=item $INPUT_RECORD_SEPARATOR
36894154
36904155=item $RS
36914156
36924157=item $/
36934158X<$/> X<$RS> X<$INPUT_RECORD_SEPARATOR>
36944159
36954160=begin original
36964161
3697The input record separator, newline by default. This influences Perl's
4162The input record separator, newline by default. This influences Perl's
3698idea of what a "line" is. Works like B<awk>'s RS variable, including
4163idea of what a "line" is. Works like B<awk>'s RS variable, including
36994164treating empty lines as a terminator if set to the null string (an
3700empty line cannot contain any spaces or tabs). You may set it to a
4165empty line cannot contain any spaces or tabs). You may set it to a
37014166multi-character string to match a multi-character terminator, or to
3702C<undef> to read through the end of file. Setting it to C<"\n\n">
4167C<undef> to read through the end of file. Setting it to C<"\n\n">
37034168means something slightly different than setting to C<"">, if the file
3704contains consecutive empty lines. Setting to C<""> will treat two or
4169contains consecutive empty lines. Setting to C<""> will treat two or
3705more consecutive empty lines as a single empty line. Setting to
4170more consecutive empty lines as a single empty line. Setting to
37064171C<"\n\n"> will blindly assume that the next input character belongs to
37074172the next paragraph, even if it's a newline.
37084173
37094174=end original
37104175
37114176入力レコードセパレータで、デフォルトでは改行文字。
37124177これは Perl での「行」とは何か、ということに影響を与えます。
3713空文字列に設定されると、空行をセパレータとして扱うことを
4178空文字列に設定されると、空行をセパレータとして扱うことを含めて、B<awk> の
3714含めて、B<awk> の変数 RS のように働きます。
4179変数 RS のように働きます(空行はスペースやタブを含んでいてはいけません)
3715(空行はスペースやタブ含んいてはいけせん。)
4180複数文字の区切文字示すために、文字列を設定することもす; また、
3716複数文字区切文字を示すために、文字列定することもできます。
4181ファイル最後まで読み込むために undef 定することもできます。
3717また、ファイルの最後まで読み込むために undef を指定することもできます。
37184182この変数に C<"\n\n"> を設定すると、空行が続く場合において、
37194183C<""> を設定した場合とわずかに違う動作をするようになります。
37204184C<""> を設定した場合には、複数の空行も 1 つの空行であるかのように扱います。
37214185C<"\n\n"> を設定した場合には、単純に次の文字が (たとえ改行文字であっても)
37224186次の段落に含まれるものとして扱います。
37234187
4188=begin original
4189
37244190 local $/; # enable "slurp" mode
37254191 local $_ = <FH>; # whole file now here
37264192 s/\n[ \t]+/ /g;
37274193
4194=end original
4195
4196 local $/; # 「吸い込み」モードを有効にする
4197 local $_ = <FH>; # ファイル全体が入る
4198 s/\n[ \t]+/ /g;
4199
37284200=begin original
37294201
3730Remember: the value of C<$/> is a string, not a regex. B<awk> has to
4202Remember: the value of C<$/> is a string, not a regex. B<awk> has to
37314203be better for something. :-)
37324204
37334205=end original
37344206
37354207注意: C<$/> は文字列であり、正規表現ではありません。
37364208B<awk> は何かもっとうまくやらなくてはいけません。:-)
37374209
37384210=begin original
37394211
4212Setting C<$/> to an empty string -- the so-called I<paragraph mode> -- merits
4213special attention. When C<$/> is set to C<""> and the entire file is read in
4214with that setting, any sequence of one or more consecutive newlines at the
4215beginning of the file is discarded. With the exception of the final record in
4216the file, each sequence of characters ending in two or more newlines is
4217treated as one record and is read in to end in exactly two newlines. If the
4218last record in the file ends in zero or one consecutive newlines, that record
4219is read in with that number of newlines. If the last record ends in two or
4220more consecutive newlines, it is read in with two newlines like all preceding
4221records.
4222
4223=end original
4224
4225C<$/> に空文字列を設定すること -- I<段落モード> と呼ばれます -- には、
4226特に注意する価値があります。
4227C<$/> が C<""> に設定されて、ファイル全体がこの設定で読み込まれた場合、
4228ファイル先頭の一つ以上の連続する改行の並びは捨てられます。
4229ファイルの最後のレコードを例外として、
4230二つ以上の改行で終わるそれぞれの文字並びは一つのレコードとして扱われ、
4231正確に二つの改行で終わるように読み込まれます。
4232ファイルの最後のレコードが 0 または 1 の連続する改行で終わっている場合、
4233そのレコードはその数の改行と共に読み込まれます。
4234最後のレコードが二つ以上の連続する改行で終わっている場合、
4235全ての先行するレコードと同様、二つの改行と共に読み込まれます。
4236
4237=begin original
4238
4239Suppose we wrote the following string to a file:
4240
4241=end original
4242
4243次の文字列をファイルに書いたとします:
4244
4245 my $string = "\n\n\n";
4246 $string .= "alpha beta\ngamma delta\n\n\n";
4247 $string .= "epsilon zeta eta\n\n";
4248 $string .= "theta\n";
4249
4250 my $file = 'simple_file.txt';
4251 open my $OUT, '>', $file or die;
4252 print $OUT $string;
4253 close $OUT or die;
4254
4255=begin original
4256
4257Now we read that file in paragraph mode:
4258
4259=end original
4260
4261このファイルを段落モードで読み込みます:
4262
4263 local $/ = ""; # paragraph mode
4264 open my $IN, '<', $file or die;
4265 my @records = <$IN>;
4266 close $IN or die;
4267
4268=begin original
4269
4270C<@records> will consist of these 3 strings:
4271
4272=end original
4273
4274C<@records> は三つの文字列からなります:
4275
4276 (
4277 "alpha beta\ngamma delta\n\n",
4278 "epsilon zeta eta\n\n",
4279 "theta\n",
4280 )
4281
4282=begin original
4283
37404284Setting C<$/> to a reference to an integer, scalar containing an
37414285integer, or scalar that's convertible to an integer will attempt to
37424286read records instead of lines, with the maximum record size being the
3743referenced integer. So this:
4287referenced integer number of characters. So this:
37444288
37454289=end original
37464290
37474291C<$/> に整数、整数を含むスカラ、整数に変換できるスカラのいずれかへの
3748リファレンスをセットすると、行を読む代わりにレコードを読もうとします
4292リファレンスをセットすると、行を読む代わりにレコードを読もうとします;
3749この場合、最大レコードサイズはリファレンス先の整数値となります。つまり:
4293この場合、最大レコードサイズはリファレンス先の整数値の文字数となります。
4294つまり:
37504295
37514296 local $/ = \32768; # or \"32768", or \$var_containing_32768
37524297 open my $fh, "<", $myfile or die $!;
37534298 local $_ = <$fh>;
37544299
37554300=begin original
37564301
3757will read a record of no more than 32768 bytes from FILE. If you're
4302will read a record of no more than 32768 characters from $fh. If you're
37584303not reading from a record-oriented file (or your OS doesn't have
37594304record-oriented files), then you'll likely get a full chunk of data
3760with every read. If a record is larger than the record size you've
4305with every read. If a record is larger than the record size you've
3761set, you'll get the record back in pieces. Trying to set the record
4306set, you'll get the record back in pieces. Trying to set the record
3762size to zero or less will cause reading in the (rest of the) whole file.
4307size to zero or less is deprecated and will cause $/ to have the value
4308of "undef", which will cause reading in the (rest of the) whole file.
37634309
37644310=end original
37654311
3766これは FILE から 32768 バイトを超えないようにレコードを読み込みます。
4312これは $fh から 32768 文字を超えないようにレコードを読み込みます。
3767もしレコード指向のファイルを読み込まない場合
4313もしレコード指向のファイルを読み込まない場合(あるいは OS がレコード指向
3768(あるいは OS がレコード指向ファイルを持たない場合)、
4314ファイルを持たない場合)、読み込み毎にデータのチャンク全部を取り込みます。
3769読み込み毎にデータのチャンク全部を取り込みます。
37704315もしレコードがセットしたレコードサイズより大きい場合、
37714316レコードの部分を取り込みます。
3772レコードサイズを 0 以下にセットしようとすると、(残り)ファイル全体を
4317レコードサイズを 0 以下にセットしようとするのは廃止予定で、
3773読み込むことになります。
4318$/ に値 "undef" が設定され、(残りの)ファイル全体を読み込むことになります。
37744319
37754320=begin original
37764321
3777On VMS, record reads are done with the equivalent of C<sysread>,
4322As of 5.19.9 setting C<$/> to any other form of reference will throw a
3778so it's best not to mix record and non-record reads on the same
4323fatal exception. This is in preparation for supporting new ways to set
3779file. (This is unlikely to be a problem, because any file you'd
4324C<$/> in the future.
3780want to read in record mode is probably unusable in line mode.)
3781Non-VMS systems do normal I/O, so it's safe to mix record and
3782non-record reads of a file.
37834325
37844326=end original
37854327
3786VMS ではレコード読み込みは C<sysread> と等価行われますで、
43285.19.9 から、C<$/> に他の形式のリファレンスを設定すると致命的エラーが
3787レコード読み込みと非レコード読み込みを同じファイルで混ぜないのが
4329投げられます。
3788最善です。(これはあまり問題なりませんなぜなら
4330これは将来 C<$/> を設定する新しい方法対応する準備です
3789レコード読み込みしたいファイルは多分行モードでは使えないものだからです。)
3790VMS 以外のシステムでは普通の I/O を使いますので、
3791同じファイルのレコード読み込みと非レコード読み込みを混ぜても安全です。
37924331
37934332=begin original
37944333
3795See also L<perlport/"Newlines">. Also see C<$.>.
4334On VMS only, record reads bypass PerlIO layers and any associated
4335buffering, so you must not mix record and non-record reads on the
4336same filehandle. Record mode mixes with line mode only when the
4337same buffering layer is in use for both modes.
37964338
37974339=end original
37984340
3799L<perlport/"Newlines"> C<$.> も参照してください。
4341VMS だけでは、レコードは PerlIO それに関連するバッファリングを迂回して
4342読み込まれるので、同じファイルハンドルでレコード読み込みと
4343非レコード読み込みを混ぜてはいけません。
4344レコードモードは、同じバッファリング層を両方のモードで使う場合にのみ
4345ラインモードと混ざります。
38004346
38014347=begin original
38024348
4349You cannot call C<input_record_separator()> on a handle, only as a
4350static method. See L<IO::Handle|IO::Handle>.
4351
4352=end original
4353
4354ハンドルに対して C<input_record_separator()> を呼び出すことはできません;
4355静的メソッドしてのみです。
4356L<IO::Handle|IO::Handle> を参照してください。
4357
4358=begin original
4359
4360See also L<perlport/"Newlines">. Also see L</$.>.
4361
4362=end original
4363
4364L<perlport/"Newlines"> を参照してください。
4365L</$.> も参照してください。
4366
4367=begin original
4368
38034369Mnemonic: / delimits line boundaries when quoting poetry.
38044370
38054371=end original
38064372
38074373記憶法: /は、詩を引用するときに、行の区切りを示します。
38084374
3809=item Handle->output_record_separator( EXPR )
4375=item IO::Handle->output_record_separator( EXPR )
38104376
38114377=item $OUTPUT_RECORD_SEPARATOR
38124378
38134379=item $ORS
38144380
38154381=item $\
38164382X<$\> X<$ORS> X<$OUTPUT_RECORD_SEPARATOR>
38174383
38184384=begin original
38194385
3820The output record separator for the print operator. If defined, this
4386The output record separator for the print operator. If defined, this
3821value is printed after the last of print's arguments. Default is C<undef>.
4387value is printed after the last of print's arguments. Default is C<undef>.
38224388
38234389=end original
38244390
38254391print 演算子のための出力レコードセパレータ。
38264392もし定義されていると、print の最後の引数の最後にこの値が表示されます。
38274393デフォルトは C<undef> です。
38284394
38294395=begin original
38304396
4397You cannot call C<output_record_separator()> on a handle, only as a
4398static method. See L<IO::Handle|IO::Handle>.
4399
4400=end original
4401
4402ハンドルに対して C<output_record_separator()> を呼び出すことはできません;
4403静的メソッドしてのみです。
4404L<IO::Handle|IO::Handle> を参照してください。
4405
4406=begin original
4407
38314408Mnemonic: you set C<$\> instead of adding "\n" at the end of the print.
38324409Also, it's just like C<$/>, but it's what you get "back" from Perl.
38334410
38344411=end original
38354412
38364413記憶法: print の最後に "\n" を付け加える代わりに C<$\> を設定する。
38374414また、C<$/> に似通っているが、Perl から「バック」されるものです。
38384415
38394416=item HANDLE->autoflush( EXPR )
38404417
38414418=item $OUTPUT_AUTOFLUSH
38424419
38434420=item $|
38444421X<$|> X<autoflush> X<flush> X<$OUTPUT_AUTOFLUSH>
38454422
38464423=begin original
38474424
38484425If set to nonzero, forces a flush right away and after every write or
3849print on the currently selected output channel. Default is 0
4426print on the currently selected output channel. Default is 0
38504427(regardless of whether the channel is really buffered by the system or
38514428not; C<$|> tells you only whether you've asked Perl explicitly to
3852flush after each write). STDOUT will typically be line buffered if
4429flush after each write). STDOUT will typically be line buffered if
3853output is to the terminal and block buffered otherwise. Setting this
4430output is to the terminal and block buffered otherwise. Setting this
38544431variable is useful primarily when you are outputting to a pipe or
38554432socket, such as when you are running a Perl program under B<rsh> and
3856want to see the output as it's happening. This has no effect on input
4433want to see the output as it's happening. This has no effect on input
3857buffering. See L<perlfunc/getc> for that. See L<perlfunc/select> on
4434buffering. See L<perlfunc/getc> for that. See L<perlfunc/select> on
3858how to select the output channel. See also L<IO::Handle>.
4435how to select the output channel. See also L<IO::Handle>.
38594436
38604437=end original
38614438
38620 以外に設定されると、
44390 以外に設定されると、その時点で選択されている出力チャネルを直ちにその場で
3863その時点で選択れている出力チャネル
4440フラッシュし、らに write や print 行なうごとに、強制的にフラッシュします。
3864直ちにその場でラッュし、
4441ォルトでは 0 となっています(チャンネルが実際にステムによって
3865らに write や print を行なごとに、強制的にフラッシュしま
4442バッファリングれているかどかは関知しません
3866デフォルトで0 となっていま
4443C<$|> Perl が明示的に毎回書き込みの後にフラッシュるかどうかのみを
3867(チャンネルが実際にシステムによってバッファリングされているかどうかは
4444示します)。
3868関知しません。C<$|> は Perl が明示的に毎回書き込みの後に
3869フラッシュするかどうかのみを示します)。
38704445STDOUT は通常では、端末への出力時には行バッファリング、
38714446それ以外ではブロックバッファリングであることに注意してください。
3872これは、Perl のスクリプトを rsh 配下で実行して、
4447これは、Perl のスクリプトを rsh 配下で実行して、実行状況を確認したい
3873実行状況を確認したい場合のように、パイプやソケットに出力するときに特に
4448場合のように、パイプやソケットに出力するときに特に便利でしょう。
3874便利でしょう。
38754449これは入力バッファリングには何の影響も与えません。
38764450出力チャネルの選択方法については L<perlfunc/select> を参照してください。
38774451L<IO::Handle> も参照してください。
38784452
38794453=begin original
38804454
38814455Mnemonic: when you want your pipes to be piping hot.
38824456
38834457=end original
38844458
38854459記憶法: パイプをホットな状態にしておくために使う。
38864460
4461=item ${^LAST_FH}
4462X<${^LAST_FH}>
4463
4464=begin original
4465
4466This read-only variable contains a reference to the last-read filehandle.
4467This is set by C<< <HANDLE> >>, C<readline>, C<tell>, C<eof> and C<seek>.
4468This is the same handle that C<$.> and C<tell> and C<eof> without arguments
4469use. It is also the handle used when Perl appends ", <STDIN> line 1" to
4470an error or warning message.
4471
4472=end original
4473
4474この読み込み専用変数は最後に読み込んだファイルハンドルへのリファレンスを
4475含んでいます。
4476これは C<< <HANDLE> >>, C<readline>, C<tell>, C<eof>, C<seek> で
4477設定されます。
4478これは C<$.> および、C<tell> と C<eof> が引数なしで使われたときと同じ
4479ハンドルです。
4480これはまた、Perl がエラーまたは警告メッセージに ", <STDIN> line 1" を追加する
4481ハンドルでもあります。
4482
4483=begin original
4484
4485This variable was added in Perl v5.18.0.
4486
4487=end original
4488
4489この変数は Perl v5.18.0 で追加されました。
4490
38874491=back
38884492
38894493=head3 Variables related to formats
38904494
38914495(フォーマット関連の変数)
38924496
38934497=begin original
38944498
38954499The special variables for formats are a subset of those for
3896filehandles. See L<perlform> for more information about Perl's
4500filehandles. See L<perlform> for more information about Perl's
38974501formats.
38984502
38994503=end original
39004504
39014505フォーマットのための特殊変数はファイルハンドルのための物のサブセットです。
39024506Perl のフォーマットに関するさらなる情報については L<perlform> を
39034507参照してください。
39044508
39054509=over 8
39064510
39074511=item $ACCUMULATOR
39084512
39094513=item $^A
39104514X<$^A> X<$ACCUMULATOR>
39114515
39124516=begin original
39134517
39144518The current value of the C<write()> accumulator for C<format()> lines.
39154519A format contains C<formline()> calls that put their result into
3916C<$^A>. After calling its format, C<write()> prints out the contents
4520C<$^A>. After calling its format, C<write()> prints out the contents
3917of C<$^A> and empties. So you never really see the contents of C<$^A>
4521of C<$^A> and empties. So you never really see the contents of C<$^A>
3918unless you call C<formline()> yourself and then look at it. See
4522unless you call C<formline()> yourself and then look at it. See
39194523L<perlform> and L<perlfunc/"formline PICTURE,LIST">.
39204524
39214525=end original
39224526
39234527C<format()> 行のための、その時点での C<write()> アキュムレータの値。
39244528format には、C<$^A> に結果を残す、C<formline()> 呼び出しが含まれます。
39254529自分のフォーマットを呼び出した後で、
39264530C<write()> は C<$^A> の内容を出力してから消去します。
39274531したがって、自分で C<formline()> を呼び出すのでなければ、
39284532C<$^A> の値が見えることはありません。
39294533L<perlform> と L<perlfunc/"formline PICTURE,LIST"> を参照してください。
39304534
3931=item HANDLE->format_formfeed(EXPR)
4535=item IO::Handle->format_formfeed(EXPR)
39324536
39334537=item $FORMAT_FORMFEED
39344538
39354539=item $^L
39364540X<$^L> X<$FORMAT_FORMFEED>
39374541
39384542=begin original
39394543
3940What formats output as a form feed. The default is C<\f>.
4544What formats output as a form feed. The default is C<\f>.
39414545
39424546=end original
39434547
39444548フォーマット出力で、改ページのために出力されるもの。
39454549デフォルトは C<\f>。
39464550
4551=begin original
4552
4553You cannot call C<format_formfeed()> on a handle, only as a static
4554method. See L<IO::Handle|IO::Handle>.
4555
4556=end original
4557
4558ハンドルに対して C<format_formfeed()> を呼び出すことはできません;
4559静的メソッドしてのみです。
4560L<IO::Handle|IO::Handle> を参照してください。
4561
39474562=item HANDLE->format_page_number(EXPR)
39484563
39494564=item $FORMAT_PAGE_NUMBER
39504565
39514566=item $%
39524567X<$%> X<$FORMAT_PAGE_NUMBER>
39534568
39544569=begin original
39554570
39564571The current page number of the currently selected output channel.
39574572
39584573=end original
39594574
39604575その時点で選択されている出力チャネルの、その時点でのページ番号。
39614576
39624577=begin original
39634578
39644579Mnemonic: C<%> is page number in B<nroff>.
39654580
39664581=end original
39674582
39684583記憶法: C<%> は、B<nroff> でのページ番号です。
39694584
39704585=item HANDLE->format_lines_left(EXPR)
39714586
39724587=item $FORMAT_LINES_LEFT
39734588
39744589=item $-
39754590X<$-> X<$FORMAT_LINES_LEFT>
39764591
39774592=begin original
39784593
39794594The number of lines left on the page of the currently selected output
4595channel.
39804596
39814597=end original
39824598
39834599その時点で選択されている出力チャネルの、ページに残っている行数。
3984フォーマットで用いられます。
39854600
39864601=begin original
39874602
39884603Mnemonic: lines_on_page - lines_printed.
39894604
39904605=end original
39914606
39924607記憶法: "ページ行数" - "印字済み行数"
39934608
3994=item Handle->format_line_break_characters EXPR
4609=item IO::Handle->format_line_break_characters EXPR
39954610
39964611=item $FORMAT_LINE_BREAK_CHARACTERS
39974612
39984613=item $:
39994614X<$:> X<FORMAT_LINE_BREAK_CHARACTERS>
40004615
40014616=begin original
40024617
40034618The current set of characters after which a string may be broken to
4004fill continuation fields (starting with C<^>) in a format. The default is
4619fill continuation fields (starting with C<^>) in a format. The default is
40054620S<" \n-">, to break on a space, newline, or a hyphen.
40064621
40074622=end original
40084623
4009フォーマットの充填継続フィールド (C<^> で始まるもの) への
4624フォーマットの充填継続フィールド (C<^> で始まるもの) への文字列で行分割を許す
4010文字列で行分割を許す文字集合。
4625文字集合。
4011デフォルトは S<" \n-"> で空白、改行、ハイフンの後で行分割が可能となっています。
4626デフォルトは S<" \n-"> で空白、改行、ハイフンの後で行分割が可能す。
40124627
40134628=begin original
40144629
4630You cannot call C<format_line_break_characters()> on a handle, only as
4631a static method. See L<IO::Handle|IO::Handle>.
4632
4633=end original
4634
4635ハンドルに対して C<format_line_break_characters()> を呼び出すことはできません;
4636静的メソッドしてのみです。
4637L<IO::Handle|IO::Handle> を参照してください。
4638
4639=begin original
4640
40154641Mnemonic: a "colon" in poetry is a part of a line.
40164642
40174643=end original
40184644
40194645記憶法: 詩では「コロン」は、行の一部。
40204646
40214647=item HANDLE->format_lines_per_page(EXPR)
40224648
40234649=item $FORMAT_LINES_PER_PAGE
40244650
40254651=item $=
40264652X<$=> X<$FORMAT_LINES_PER_PAGE>
40274653
40284654=begin original
40294655
40304656The current page length (printable lines) of the currently selected
4031output channel. The default is 60.
4657output channel. The default is 60.
40324658
40334659=end original
40344660
4035その時点で選択されている出力チャネルの、その時点での
4661その時点で選択されている出力チャネルの、その時点でのページ長(印字可能行数)。
4036ページ長 (印字可能行数)。デフォルトは 60 です。
4662デフォルトは 60 です。
4037フォーマットで用いられます。
40384663
40394664=begin original
40404665
40414666Mnemonic: = has horizontal lines.
40424667
40434668=end original
40444669
40454670記憶法: = には複数の水平線 (行) が含まれます。
40464671
40474672=item HANDLE->format_top_name(EXPR)
40484673
40494674=item $FORMAT_TOP_NAME
40504675
40514676=item $^
40524677X<$^> X<$FORMAT_TOP_NAME>
40534678
40544679=begin original
40554680
40564681The name of the current top-of-page format for the currently selected
4057output channel. The default is the name of the filehandle with C<_TOP>
4682output channel. The default is the name of the filehandle with C<_TOP>
4058appended. For example, the default format top name for the C<STDOUT>
4683appended. For example, the default format top name for the C<STDOUT>
4059filehanlde is C<STDOUT_TOP>.
4684filehandle is C<STDOUT_TOP>.
40604685
40614686=end original
40624687
4063その時点で選択されている出力チャネルの、その時点でのページ先頭
4688その時点で選択されている出力チャネルの、その時点でのページ先頭フォーマット名。
4064フォーマット名。
40654689デフォルトは、ファイルハンドル名に _TOP を続けたものです。
40664690例えば、C<STDOUT> ファイルハンドルのデフォルトのページ先頭フォーマット名は
40674691C<STDOUT_TOP> です。
40684692
40694693=begin original
40704694
40714695Mnemonic: points to top of page.
40724696
40734697=end original
40744698
40754699記憶法: ページの先頭へのポインタ。
40764700
40774701=item HANDLE->format_name(EXPR)
40784702
40794703=item $FORMAT_NAME
40804704
40814705=item $~
40824706X<$~> X<$FORMAT_NAME>
40834707
40844708=begin original
40854709
40864710The name of the current report format for the currently selected
4087output channel. The default format name is the same as the filehandle
4711output channel. The default format name is the same as the filehandle
4088name. For example, the default format name for the C<STDOUT>
4712name. For example, the default format name for the C<STDOUT>
40894713filehandle is just C<STDOUT>.
40904714
40914715=end original
40924716
40934717その時点で選択されている出力チャネルの、その時点でのフォーマット名。
40944718デフォルトは、ファイルハンドル名です。
40954719例えば、C<STDOUT> ファイルハンドルのデフォルトフォーマット名は
40964720単に C<STDOUT> です。
40974721
40984722=begin original
40994723
41004724Mnemonic: brother to C<$^>.
41014725
41024726=end original
41034727
41044728記憶法: C<$^> の兄弟。
41054729
41064730=back
41074731
4108=head2 Error Indicators
4732=head2 Error Variables
41094733X<error> X<exception>
41104734
4111(エラー指示子)
4735(エラー変数)
41124736
41134737=begin original
41144738
41154739The variables C<$@>, C<$!>, C<$^E>, and C<$?> contain information
41164740about different types of error conditions that may appear during
4117execution of a Perl program. The variables are shown ordered by
4741execution of a Perl program. The variables are shown ordered by
41184742the "distance" between the subsystem which reported the error and
4119the Perl process. They correspond to errors detected by the Perl
4743the Perl process. They correspond to errors detected by the Perl
41204744interpreter, C library, operating system, or an external program,
41214745respectively.
41224746
41234747=end original
41244748
41254749変数 C<$@>, C<$!>, C<$^E>, C<$?> は Perl プログラムの実行中に
41264750発生した、異なる種類のエラー情報を保持します。
4127変数はエラーを報告した副システムと Perl プロセスとの「距離」
4751変数はエラーを報告した副システムと Perl プロセスとの「距離」の順番に
4128の順番に並んでいます。
4752並んでいます。
41294753これらはそれぞれ、Perl インタプリタ、C ライブラリ、
41304754オペレーティングシステム、外部プログラムによって検出された
41314755エラーに対応しています。
41324756
41334757=begin original
41344758
41354759To illustrate the differences between these variables, consider the
4136following Perl expression, which uses a single-quoted string. After
4760following Perl expression, which uses a single-quoted string. After
41374761execution of this statement, perl may have set all four special error
41384762variables:
41394763
41404764=end original
41414765
41424766これらの変数の違いを示すために、
41434767以下のようなシングルクォートを用いた Perl 式を考えます。
41444768この文の実行後、perl は四つ全ての特殊エラー変数をセットします:
41454769
4770 eval q{
4771 open my $pipe, "/cdrom/install |" or die $!;
4772 my @res = <$pipe>;
4773 close $pipe or die "bad pipe: $?, $!";
4774 };
41464775
4147 eval q{
4148 open my $pipe, "/cdrom/install |" or die $!;
4149 my @res = <$pipe>;
4150 close $pipe or die "bad pipe: $?, $!";
4151 };
4152
41534776=begin original
41544777
41554778When perl executes the C<eval()> expression, it translates the
41564779C<open()>, C<< <PIPE> >>, and C<close> calls in the C run-time library
4157and thence to the operating system kernel. perl sets C<$!> to
4780and thence to the operating system kernel. perl sets C<$!> to
41584781the C library's C<errno> if one of these calls fails.
41594782
41604783=end original
41614784
41624785C<eval()> 式が実行されたとき、C<open()>, C<< <PIPE> >>, C<close> は
41634786C ランタイムライブラリの呼び出しに変換され、それからオペレーティング
41644787システムコールに変換されます。
41654788C<$!> はこれらの呼び出しのどれかが失敗したとき、
41664789C ライブラリの C<errno> の値がセットされます。
41674790
41684791=begin original
41694792
41704793C<$@> is set if the string to be C<eval>-ed did not compile (this may
41714794happen if C<open> or C<close> were imported with bad prototypes), or
4172if Perl code executed during evaluation C<die()>d. In these cases the
4795if Perl code executed during evaluation C<die()>d. In these cases the
41734796value of C<$@> is the compile error, or the argument to C<die> (which
4174will interpolate C<$!> and C<$?>). (See also L<Fatal>, though.)
4797will interpolate C<$!> and C<$?>). (See also L<Fatal>, though.)
41754798
41764799=end original
41774800
4178C<$@> は C<eval> された文字列がコンパイルされなかったとき
4801C<$@> は C<eval> された文字列がコンパイルされなかったとき(これは C<open> か
4179(これは C<open> か C<close> が正しくない
4802C<close> が正しくないプロトタイプでインポートされたときに起こり得ます)、
4180プロトタイプでインポートされたときに起こり得ます)、
41814803または評価中に実行している Perl コードが C<die()> したときにセットされます。
41824804これらの場合には C<$@> の値はコンパイルエラー、または
41834805C<die> への引数(これには C<$!> と C<$?> が差し挟まれます)です。
41844806(しかし、L<Fatal> も参照して下さい。)
41854807
41864808=begin original
41874809
41884810Under a few operating systems, C<$^E> may contain a more verbose error
4189indicator, such as in this case, "CDROM tray not closed." Systems that
4811indicator, such as in this case, "CDROM tray not closed." Systems that
41904812do not support extended error messages leave C<$^E> the same as C<$!>.
41914813
41924814=end original
41934815
4194いくつかのオペレーティングシステムでは、
4816いくつかのオペレーティングシステムでは、C<$^E> により詳細なエラー指示子が
4195C<$^E> により詳細なエラー指示子が入っているかもしれません
4817入っているかもしれません; 今回の場合で言えば、
4196今回の場合で言えば、"CDROM tray not closed." などです。
4818"CDROM tray not closed." などです。
4197追加のエラーメッセージに対応していないシステムでは、
4819追加のエラーメッセージに対応していないシステムでは、C<$^E> は C<$!> と同じ
4198C<$^E> は C<$!> と同じ値です。
4820値です。
41994821
42004822=begin original
42014823
4202Finally, C<$?> may be set to non-0 value if the external program
4824Finally, C<$?> may be set to a non-0 value if the external program
4203F</cdrom/install> fails. The upper eight bits reflect specific error
4825F</cdrom/install> fails. The upper eight bits reflect specific error
42044826conditions encountered by the program (the program's C<exit()> value).
42054827The lower eight bits reflect mode of failure, like signal death and
4206core dump information. See C<wait(2)> for details. In contrast to
4828core dump information. See L<wait(2)> for details. In contrast to
4207C<$!> and C<$^E>, which are set only if error condition is detected,
4829C<$!> and C<$^E>, which are set only if an error condition is detected,
42084830the variable C<$?> is set on each C<wait> or pipe C<close>,
4209overwriting the old value. This is more like C<$@>, which on every
4831overwriting the old value. This is more like C<$@>, which on every
42104832C<eval()> is always set on failure and cleared on success.
42114833
42124834=end original
42134835
42144836最後に、C<$?> は外部プログラム F</cdrom/install> が失敗したときに
42154837非 0 にセットされるかもしれません。
42164838上位の 8 ビットはプログラムが遭遇した特定のエラー状況
42174839(プログラムの C<exit()> の値)を反映します。
42184840下位の 8 ビットは、シグナルの死亡やコアダンプ情報と言った失敗のモードを
42194841反映します。
4220詳細については C<wait(2)> を参照して下さい。
4842詳細については L<wait(2)> を参照して下さい。
42214843C<$!> と C<$^E> はエラー状況が検出されたときにのみ設定されますが、
42224844変数 C<$?> は C<wait> やパイプの C<close> の度に、前の値を上書きします。
42234845これは、C<$@> が C<eval()> の実行毎に、エラーならセットされ、
42244846成功ならクリアされるという動作と似ています。
42254847
42264848=begin original
42274849
42284850For more details, see the individual descriptions at C<$@>, C<$!>,
42294851C<$^E>, and C<$?>.
42304852
42314853=end original
42324854
42334855より詳細については、C<$@>, C<$!>, C<$^E>, C<$?> それぞれの説明を
42344856参照して下さい。
42354857
42364858=over 8
42374859
42384860=item ${^CHILD_ERROR_NATIVE}
42394861X<$^CHILD_ERROR_NATIVE>
42404862
42414863=begin original
42424864
42434865The native status returned by the last pipe close, backtick (C<``>)
42444866command, successful call to C<wait()> or C<waitpid()>, or from the
4245C<system()> operator. On POSIX-like systems this value can be decoded
4867C<system()> operator. On POSIX-like systems this value can be decoded
4246with the WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED,
4868with the WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, and
4247WSTOPSIG and WIFCONTINUED functions provided by the L<POSIX> module.
4869WSTOPSIG functions provided by the L<POSIX> module.
42484870
42494871=end original
42504872
42514873最後のパイプクローズ、逆クォート (C<``>) コマンド、C<wait()> と
42524874C<waitpid()> の成功した呼び出し、C<system()> 演算子から返された、
42534875ネイティブなステータスです。
42544876POSIX 風システムでは、この値は L<POSIX> モジュールで提供される
4255WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG,
4877WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG 関数で
4256WIFCONTINUED 関数でデコードできます。
4878デコードできます。
42574879
42584880=begin original
42594881
42604882Under VMS this reflects the actual VMS exit status; i.e. it is the
42614883same as C<$?> when the pragma C<use vmsish 'status'> is in effect.
42624884
42634885=end original
42644886
42654887VMS ではこれは実際の VMS の終了ステータスを反映します;
42664888言い換えると、これは C<use vmsish 'status'> プラグマが有効なときの $? と
42674889同じです。
42684890
42694891=begin original
42704892
4271This variable was added in Perl 5.8.9.
4893This variable was added in Perl v5.10.0.
42724894
42734895=end original
42744896
4275この変数は Perl 5.8.9 で追加されました。
4897この変数は Perl v5.10.0 で追加されました。
42764898
42774899=item $EXTENDED_OS_ERROR
42784900
42794901=item $^E
42804902X<$^E> X<$EXTENDED_OS_ERROR>
42814903
42824904=begin original
42834905
4284Error information specific to the current operating system. At the
4906Error information specific to the current operating system. At the
4285moment, this differs from C<$!> under only VMS, OS/2, and Win32 (and
4907moment, this differs from C<L</$!>> under only VMS, OS/2, and Win32 (and
4286for MacPerl). On all other platforms, C<$^E> is always just the same
4908for MacPerl). On all other platforms, C<$^E> is always just the same
42874909as C<$!>.
42884910
42894911=end original
42904912
42914913現在のオペレーティングシステムに特化したエラー情報です。
42924914現在のところ、VMS, OS/2, Win32 (と MacPerl) のみで
4293C<$!> と異なる値をもちます。
4915C<L</$!>> と異なる値をもちます。
42944916その他のプラットフォームでは、C<$^E> はいつも C<$!> と同じです。
42954917
42964918=begin original
42974919
42984920Under VMS, C<$^E> provides the VMS status value from the last system
4299error. This is more specific information about the last system error
4921error. This is more specific information about the last system error
4300than that provided by C<$!>. This is particularly important when C<$!>
4922than that provided by C<$!>. This is particularly important when C<$!>
43014923is set to B<EVMSERR>.
43024924
43034925=end original
43044926
43054927VMS では、C<$^E> は最後のシステムエラーの VMS ステータス値です。
43064928これは、最後のシステムエラーについて C<$!> で提供されるものより
43074929具体的な情報を示します。
43084930これは特に C<$!> が B<EVMSERR> にセットされた場合に重要です。
43094931
43104932=begin original
43114933
43124934Under OS/2, C<$^E> is set to the error code of the last call to OS/2
43134935API either via CRT, or directly from perl.
43144936
43154937=end original
43164938
43174939OS/2 では、C<$^E> は CRT 経由、または Perl から直接呼び出された
43184940最後の OS/2 API のエラーコードがセットされます。
43194941
43204942=begin original
43214943
43224944Under Win32, C<$^E> always returns the last error information reported
43234945by the Win32 call C<GetLastError()> which describes the last error
4324from within the Win32 API. Most Win32-specific code will report errors
4946from within the Win32 API. Most Win32-specific code will report errors
4325via C<$^E>. ANSI C and Unix-like calls set C<errno> and so most
4947via C<$^E>. ANSI C and Unix-like calls set C<errno> and so most
43264948portable Perl code will report errors via C<$!>.
43274949
43284950=end original
43294951
43304952Win32 では、C<$^E> は Win32 API での最後のエラーの内容を返す
43314953C<GetLastError()> Win32 呼び出しで報告される最新のエラー情報を
43324954返します。
43334955ほとんどの Win32 固有のコードはエラーを C<$^E> 経由で返します。
43344956ANSI C と Unix 風の呼び出しは C<errno> をセットするので、
43354957ほとんどの移植性のある Perl コードは C<$!> 経由で
43364958エラーを報告します。
43374959
43384960=begin original
43394961
4340Caveats mentioned in the description of C<$!> generally apply to
4962Caveats mentioned in the description of C<L</$!>> generally apply to
43414963C<$^E>, also.
43424964
43434965=end original
43444966
4345C<$!> の説明で触れた問題点は一般的に C<$^E> にも適用されます。
4967C<L</$!>> の説明で触れた問題点は一般的に C<$^E> にも適用されます。
43464968
43474969=begin original
43484970
43494971This variable was added in Perl 5.003.
43504972
43514973=end original
43524974
43534975この変数は Perl 5.003 で追加されました。
43544976
43554977=begin original
43564978
43574979Mnemonic: Extra error explanation.
43584980
43594981=end original
43604982
43614983記憶法: 追加の(Extra)エラーの説明。
43624984
43634985=item $EXCEPTIONS_BEING_CAUGHT
43644986
43654987=item $^S
43664988X<$^S> X<$EXCEPTIONS_BEING_CAUGHT>
43674989
43684990=begin original
43694991
43704992Current state of the interpreter.
43714993
43724994=end original
43734995
43744996現在のインタプリタの状態を示します。
43754997
43764998=begin original
43774999
4378 $^S State
5000 $^S State
4379 --------- -------------------
5001 --------- -------------------------------------
4380 undef Parsing module/eval
5002 undef Parsing module, eval, or main program
4381 true (1) Executing an eval
5003 true (1) Executing an eval or try block
4382 false (0) Otherwise
5004 false (0) Otherwise
43835005
43845006=end original
43855007
4386 $^S 状態
5008 $^S 状態
4387 --------- -------------------
5009 --------- -------------------
4388 undef モジュール/eval のパース中
5010 undef モジュールeval、メインプログラムのパース中
4389 真 (1) eval の実行中
5011 真 (1) eval または try ブロックの実行中
4390 偽 (0) その他
5012 偽 (0) その他
43915013
43925014=begin original
43935015
43945016The first state may happen in C<$SIG{__DIE__}> and C<$SIG{__WARN__}>
43955017handlers.
43965018
43975019=end original
43985020
43995021最初の状態は C<$SIG{__DIE__}> と C<$SIG{__WARN__}> のハンドラで起きる
44005022可能性があります。
44015023
44025024=begin original
44035025
5026The English name $EXCEPTIONS_BEING_CAUGHT is slightly misleading, because
5027the C<undef> value does not indicate whether exceptions are being caught,
5028since compilation of the main program does not catch exceptions.
5029
5030=end original
5031
5032英語名 $EXCEPTIONS_BEING_CAUGHT は少し誤解を招きます; C<undef> は例外が
5033捕捉されたかどうかを示しているわけではないからです; メインプログラムの
5034コンパイルは例外を捕捉しません。
5035
5036=begin original
5037
44045038This variable was added in Perl 5.004.
44055039
44065040=end original
44075041
44085042この変数は Perl 5.004 で追加されました。
44095043
44105044=item $WARNING
44115045
44125046=item $^W
44135047X<$^W> X<$WARNING>
44145048
44155049=begin original
44165050
44175051The current value of the warning switch, initially true if B<-w> was
44185052used, false otherwise, but directly modifiable.
44195053
44205054=end original
44215055
44225056警告スイッチの値で、B<-w> スイッチが使われると内部的に真となり、
44235057そうでない場合は直接変更可能です。
44245058
44255059=begin original
44265060
44275061See also L<warnings>.
44285062
44295063=end original
44305064
44315065L<warnings> も参照して下さい。
44325066
44335067=begin original
44345068
44355069Mnemonic: related to the B<-w> switch.
44365070
44375071=end original
44385072
44395073記憶法: B<-w> スイッチに関係します。
44405074
44415075=item ${^WARNING_BITS}
44425076X<${^WARNING_BITS}>
44435077
44445078=begin original
44455079
44465080The current set of warning checks enabled by the C<use warnings> pragma.
4447See the documentation of C<warnings> for more details.
5081It has the same scoping as the C<$^H> and C<%^H> variables. The exact
5082values are considered internal to the L<warnings> pragma and may change
5083between versions of Perl.
44485084
44495085=end original
44505086
44515087C<use warnings> プラグマで有効にされた、現在の警告チェックの集合です。
4452詳細については C<warnings> のドキュメント参照して下さい
5088C<$^H> および C<%^H> 変数と同じスコープ持ちます
5089正確な値は L<warnings> プラグマの内部の値と考えられ、Perl の
5090バージョンによって変更されるかもしれません。
44535091
44545092=begin original
44555093
4456This variable was added in Perl 5.10.
5094Each time a statement completes being compiled, the current value of
5095C<${^WARNING_BITS}> is stored with that statement, and can later be
5096retrieved via C<(caller($level))[9]>.
44575097
44585098=end original
44595099
4460変数は Perl 5.10 で追加されました。
5100コンパイルが完了する毎に、C<${^WARNING_BITS}> の現在の値が文と共に
5101保管され、C<(caller($level))[9]> として後で取得できます。
44615102
5103=begin original
5104
5105This variable was added in Perl v5.6.0.
5106
5107=end original
5108
5109この変数は Perl v5.6.0 で追加されました。
5110
44625111=item $OS_ERROR
44635112
44645113=item $ERRNO
44655114
44665115=item $!
44675116X<$!> X<$ERRNO> X<$OS_ERROR>
44685117
44695118=begin original
44705119
4471If used numerically, yields the current value of the C C<errno>
5120When referenced, C<$!> retrieves the current value
4472variable, or in other words, if a system or library call fails, it
5121of the C C<errno> integer variable.
4473sets this variable. This means that the value of C<$!> is meaningful
5122If C<$!> is assigned a numerical value, that value is stored in C<errno>.
4474only I<immediately> after a B<failure>:
5123When referenced as a string, C<$!> yields the system error string
5124corresponding to C<errno>.
44755125
44765126=end original
44775127
4478数値として使われると、その時点の C の C<errno> 変数の値られます;
5128参照されると、C<$!> C の C<errno> 整数変数の現在のを取ます
4479言い換えると、もしシステムコールやライブラリ呼び出し失敗すると、
5129C<$!> に数値代入されると、その値は C<errno> に保管されます。
4480この変数がセットされ
5130文字列として参照されると、C<$!> は C<errno> に対応るシステムエラー
4481これは、C<$!> の値が意味持つのは B<失敗> の I<直後> だけということを
5131文字列返します。
4482意味します。
44835132
4484 if (open my $fh, "<", $filename) {
5133=begin original
4485 # Here $! is meaningless.
4486 ...
5135Many system or library calls set C<errno> if they fail,
5136to indicate the cause of failure. They usually do B<not>
5137set C<errno> to zero if they succeed and may set C<errno> to a
5138non-zero value on success. This means C<errno>, hence C<$!>, is
5139meaningful only I<immediately> after a B<failure>:
5140
5141=end original
5142
5143多くのシステムやライブラリ呼び出しは、失敗したときに、失敗の理由を示すために
5144C<errno> を設定します。
5145これらは普通は成功したときには C<errno> にゼロを設定 B<しません>;
5146成功時には C<errno> に非ゼロを設定するかもしれません。
5147これは、C<errno>、C<$!> は、B<失敗> の I<直後> でのみ意味が
5148あるということです:
5149
5150=begin original
5151
5152 if (open my $fh, "<", $filename) {
5153 # Here $! is meaningless.
5154 ...
44875155 }
44885156 else {
4489 # ONLY here is $! meaningful.
5157 # ONLY here is $! meaningful.
4490 ...
5158 ...
4491 # Already here $! might be meaningless.
5159 # Already here $! might be meaningless.
44925160 }
44935161 # Since here we might have either success or failure,
4494 # here $! is meaningless.
5162 # $! is meaningless.
44955163
5164=end original
5165
5166 if (open my $fh, "<", $filename) {
5167 # ここで $! は無意味。
5168 ...
5169 }
5170 else {
5171 # ここでだけ $! に意味がある。
5172 ...
5173 # ここで既に $! は無意味かもしれません。
5174 }
5175 # ここでは成功と失敗の両方の可能性があるので、
5176 # $! は無意味。
5177
44965178=begin original
44975179
4498The I<meaningless> stands for anything: zero, non-zero,
5180Here, I<meaningless> means that C<$!> may be unrelated to the outcome
4499C<undef>. A successful system or library call does B<not> set the
5181of the C<open()> operator. Assignment to C<$!> is similarly ephemeral.
4500variable to zero.
5182It can be used immediately before invoking the C<die()> operator,
5183to set the exit value, or to inspect the system error string
5184corresponding to error I<n>, or to restore C<$!> to a meaningful state.
45015185
45025186=end original
45035187
4504I<meaningless> は何でもあり得ます: 0、非 0、C<undef>
5188ここで、I<無意味> というのC<$!> C<open()> 演算子の結果に
4505システムコールやライブラリ呼び出しが成功した場合は、の変数は 0 に
5189関係ないというとです。
4506セット B<されません>。
5190C<$!> への代入も同様に一時的なものです
5191これは、終了値を設定したり、エラー I<n> に対応するシステムエラー文字列を
5192調べたり、C<$!> を意味のある状態に復元するために、C<die()> 演算子を
5193起動する直前で使えます。
45075194
45085195=begin original
45095196
4510If used as a string, yields the corresponding system error string. You
5197Perl itself may set C<errno> to a non-zero on failure even if no
4511can assign a number to C<$!> to set I<errno> if, for instance, you
5198system call is performed.
4512want C<"$!"> to return the string for error I<n>, or you want to set
4513the exit value for the C<die()> operator.
45145199
45155200=end original
45165201
4517文字列として使われると対応するシステムエラのメッセージ文字列が得られます。
5202Perl 自身は、システムルを実行しなくても失敗時には
4518たとえば、C<$!> にエラーの文字列返して欲しいならば、あいは、
5203C<errno> に非ゼロ設定すかもしれません。
4519C<die()> 演算子の exit 値を設定するために、I<errno> を設定するため
4520C<$!> へ代入を行なうことが可能です。
45215204
45225205=begin original
45235206
45245207Mnemonic: What just went bang?
45255208
45265209=end original
45275210
45285211記憶法: 何が bang(!) したか。
45295212
45305213=item %OS_ERROR
45315214
45325215=item %ERRNO
45335216
45345217=item %!
45355218X<%!> X<%OS_ERROR> X<%ERRNO>
45365219
45375220=begin original
45385221
45395222Each element of C<%!> has a true value only if C<$!> is set to that
4540value. For example, C<$!{ENOENT}> is true if and only if the current
5223value. For example, C<$!{ENOENT}> is true if and only if the current
45415224value of C<$!> is C<ENOENT>; that is, if the most recent error was "No
45425225such file or directory" (or its moral equivalent: not all operating
4543systems give that exact error, and certainly not all languages). To
5226systems give that exact error, and certainly not all languages). The
4544check if a particular key is meaningful on your system, use C<exists
5227specific true value is not guaranteed, but in the past has generally
4545$!{the_key}>; for a list of legal keys, use C<keys %!>. See L<Errno>
5228been the numeric value of C<$!>. To check if a particular key is
4546for more information, and also see L</$!>.
5229meaningful on your system, use C<exists $!{the_key}>; for a list of legal
5230keys, use C<keys %!>. See L<Errno> for more information, and also see
5231L</$!>.
45475232
45485233=end original
45495234
4550C<%!> の各要素は、C<$!> がその値にセットされている場合にのみ真の値を
5235C<%!> の各要素は、C<$!> がその値にセットされている場合にのみ真の値を持ちます。
4551持ちます。
45525236例えば、C<$!{ENOENT}> は、現在の C<$!> の値が C<ENOENT> の場合にのみ
4553真となります; これは、最近のエラーが
5237真となります; これは、最近のエラーが "No such file or directory" (あるいは
4554"No such file or directory" (あるいは倫理的に等価なもの: 全ての OS が正確に
5238倫理的に等価なもの: 全ての OS が正確に同じエラーを出すわけではないですし、
4555同じエラーを出すわけではないですし、全ての言語で出るわけでもありません) の
5239全ての言語で出るわけでもありません) の場合です。
4556場合
5240特定の真の値は保証されませんが、以前は一般的には C<$!> の数値した
45575241あなたのシステムで特定のキーが意味があるかどうかを調べるには、
45585242C<exists $!{the_key}> を使ってください; 有効なキーのリストを得るには、
45595243C<keys %!> としてください。
45605244さらなる情報に関しては L<Errno> と C</$!> を参照してください。
45615245
45625246=begin original
45635247
45645248This variable was added in Perl 5.005.
45655249
45665250=end original
45675251
45685252この変数は Perl 5.005 で追加されました。
45695253
45705254=item $CHILD_ERROR
45715255
45725256=item $?
45735257X<$?> X<$CHILD_ERROR>
45745258
45755259=begin original
45765260
45775261The status returned by the last pipe close, backtick (C<``>) command,
45785262successful call to C<wait()> or C<waitpid()>, or from the C<system()>
4579operator. This is just the 16-bit status word returned by the
5263operator. This is just the 16-bit status word returned by the
45805264traditional Unix C<wait()> system call (or else is made up to look
4581like it). Thus, the exit value of the subprocess is really (C<<< $? >>
5265like it). Thus, the exit value of the subprocess is really (C<<< $? >>
458252668 >>>), and C<$? & 127> gives which signal, if any, the process died
45835267from, and C<$? & 128> reports whether there was a core dump.
45845268
45855269=end original
45865270
45875271最後に close したパイプ、バッククォート (C<``>) コマンド、
45885272成功した C<wait()> または waitpid() 呼び出し、C<system()> 演算子が返した
45895273ステータス。
45905274このステータスワードは伝統的な Unix の C<wait()> システムコールが返した
4591527516 ビットのステータス(またはそのように見えるもの)です。
45925276従ってサブプロセスの exit 値は、実際には (C<<< $? >> 8 >>>)
45935277で、C<$? & 127> は、もしあれば、そのプロセスを止めたシグナルで、
45945278C<$? & 128> はコアダンプがあるかどうかを示します。
45955279
45965280=begin original
45975281
45985282Additionally, if the C<h_errno> variable is supported in C, its value
45995283is returned via C<$?> if any C<gethost*()> function fails.
46005284
46015285=end original
46025286
46035287さらに、C で C<h_errno> 変数に対応している場合は、
46045288C<gethost*()> が失敗したときに C<$?> を通して返されます。
46055289
46065290=begin original
46075291
46085292If you have installed a signal handler for C<SIGCHLD>, the
46095293value of C<$?> will usually be wrong outside that handler.
46105294
46115295=end original
46125296
46135297C<SIGCHLD> のシグナルハンドラを設定した場合、
46145298C<$?> の値は通常ハンドラの外側では正しくない値となります。
46155299
46165300=begin original
46175301
46185302Inside an C<END> subroutine C<$?> contains the value that is going to be
4619given to C<exit()>. You can modify C<$?> in an C<END> subroutine to
5303given to C<exit()>. You can modify C<$?> in an C<END> subroutine to
4620change the exit status of your program. For example:
5304change the exit status of your program. For example:
46215305
46225306=end original
46235307
46245308C<END> サブルーチンの内側では C<$?> には C<exit()> に渡されようとしている
46255309値を含みます。
46265310プログラムの終了ステータスを変更するために、C<END> サブルーチン 内で
46275311C<$?> を変更できます。
46285312例えば:
46295313
5314=begin original
5315
46305316 END {
4631 $? = 1 if $? == 255; # die would make it 255
5317 $? = 1 if $? == 255; # die would make it 255
46325318 }
46335319
5320=end original
5321
5322 END {
5323 $? = 1 if $? == 255; # die は 255
5324 }
5325
46345326=begin original
46355327
46365328Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect the
46375329actual VMS exit status, instead of the default emulation of POSIX
46385330status; see L<perlvms/$?> for details.
46395331
46405332=end original
46415333
46425334VMS では、C<use vmsish 'status'> を指定すると、
46435335C<$?> はPOSIX ステータスをエミュレートしたものではなく、
46445336実際の VMS 終了ステータスを反映します; 詳細は L<perlvms/$?> を
46455337参照してください。
46465338
46475339=begin original
46485340
46495341Mnemonic: similar to B<sh> and B<ksh>.
46505342
46515343=end original
46525344
46535345記憶法: B<sh> や B<ksh> と同様。
46545346
46555347=item $EVAL_ERROR
46565348
46575349=item $@
46585350X<$@> X<$EVAL_ERROR>
46595351
46605352=begin original
46615353
4662The Perl syntax error message from the last C<eval()> operator. If C<$@> is
5354The Perl error from the last C<eval> operator, i.e. the last exception that
4663the null string, the last C<eval()> parsed and executed correctly
5355was caught. For C<eval BLOCK>, this is either a runtime error message or the
4664(although the operations you invoked may have failed in the normal
5356string or reference C<die> was called with. The C<eval STRING> form also
4665fashion).
5357catches syntax errors and other compile time exceptions.
46665358
46675359=end original
46685360
4669最後の C<eval()> 操作子による Perl の構文エラーメッセージです
5361最後の C<eval> 操作子による Perl のエラーです; つまり、最後に補足された
4670C<$@> が空文字列あれば、最後の C<eval()> が正常に
5362例外す。
4671解析され、実行されたになります (が、実行した演算子が、
5363C<eval BLOCK> の場合はこれは実行時エラーか、C<die> が呼び出されたときの
4672通常の意味で失敗しているもしれません)
5364文字列リファレンスです
5365C<eval STRING> 型式は、文法エラーやその他のコンパイル時例外も捕捉します。
46735366
46745367=begin original
46755368
4676Warning messages are not collected in this variable. You can, however,
5369If no error occurs, C<eval> sets C<$@> to the empty string.
5370
5371=end original
5372
5373エラーが起きなければ、C<eval> は C<$@> に空文字列を設定します。
5374
5375=begin original
5376
5377Warning messages are not collected in this variable. You can, however,
46775378set up a routine to process warnings by setting C<$SIG{__WARN__}> as
46785379described in L</%SIG>.
46795380
46805381=end original
46815382
46825383警告メッセージはこの変数に入りません。
46835384しかし、L</%SIG> に記述されている C<$SIG{__WARN__}> にセットすることで
46845385警告を処理するルーチンを設定できます。
46855386
46865387=begin original
46875388
4688Mnemonic: Where was the syntax error "at"?
5389Mnemonic: Where was the error "at"?
46895390
46905391=end original
46915392
4692記憶法: どこで ("at") 構文エラーが起ったか。
5393記憶法: どこで ("at") エラーが起ったか。
46935394
46945395=back
46955396
5397=head2 Variables related to the interpreter state
5398
5399(インタプリタの状態に関連する変数)
5400
5401=begin original
5402
5403These variables provide information about the current interpreter state.
5404
5405=end original
5406
5407これらの変数は現在のインタプリタの状態に関する情報を提供します。
5408
5409=over 8
5410
5411=item $COMPILING
5412
5413=item $^C
5414X<$^C> X<$COMPILING>
5415
5416=begin original
5417
5418The current value of the flag associated with the B<-c> switch.
5419Mainly of use with B<-MO=...> to allow code to alter its behavior
5420when being compiled, such as for example to C<AUTOLOAD> at compile
5421time rather than normal, deferred loading. Setting
5422C<$^C = 1> is similar to calling C<B::minus_c>.
5423
5424=end original
5425
5426B<-c> スイッチに関連付けられた現在の値です。
5427主に B<-MO=...> と共に用いられ、例えば C<AUTOLOAD> を通常の遅延ロードでは
5428なくコンパイル時に実行するといった、コンパイル時の振る舞いを
5429変えるために用います。
5430C<$^C = 1> に設定することは C<B::minus_c> を呼び出すのと似ています。
5431
5432=begin original
5433
5434This variable was added in Perl v5.6.0.
5435
5436=end original
5437
5438この変数は Perl v5.6.0 で追加されました。
5439
5440=item $DEBUGGING
5441
5442=item $^D
5443X<$^D> X<$DEBUGGING>
5444
5445=begin original
5446
5447The current value of the debugging flags. May be read or set. Like its
5448L<command-line equivalent|perlrun/B<-D>I<letters>>, you can use numeric
5449or symbolic values, e.g. C<$^D = 10> or C<$^D = "st">. See
5450L<perlrun/B<-D>I<number>>. The contents of this variable also affects the
5451debugger operation. See L<perldebguts/Debugger Internals>.
5452
5453=end original
5454
5455デバッグフラグの現在の値を示します。
5456読み書き可能です。
5457L<コマンドラインによる等価な機能|perlrun/B<-D>I<letters>> と同様に、
5458数値とシンボル値が使えます
5459(例: C<$^D = 10> または C<$^D = "st">)。
5460L<perlrun/B<-D>I<number>> を参照してください。
5461この変数の内容はデバッガ操作にも影響されます。
5462L<perldebguts/Debugger Internals> を参照してください。
5463
5464=begin original
5465
5466Mnemonic: value of B<-D> switch.
5467
5468=end original
5469
5470記憶法: B<-D> スイッチの値。
5471
5472=item ${^GLOBAL_PHASE}
5473X<${^GLOBAL_PHASE}>
5474
5475=begin original
5476
5477The current phase of the perl interpreter.
5478
5479=end original
5480
5481perl インタプリタの現在のフェーズ。
5482
5483=begin original
5484
5485Possible values are:
5486
5487=end original
5488
5489取り得る値は:
5490
5491=over 8
5492
5493=item CONSTRUCT
5494
5495=begin original
5496
5497The C<PerlInterpreter*> is being constructed via C<perl_construct>. This
5498value is mostly there for completeness and for use via the
5499underlying C variable C<PL_phase>. It's not really possible for Perl
5500code to be executed unless construction of the interpreter is
5501finished.
5502
5503=end original
5504
5505C<PerlInterpreter*> は C<perl_construct> で構築されます。
5506この変数はほとんど完全性のためと、基礎となっている C 変数
5507C<PL_phase> 経由での使用のために存在しています。
5508実際にはインタプリタの構築が完了しない限り Perl コードを
5509実行することはできません。
5510
5511=item START
5512
5513=begin original
5514
5515This is the global compile-time. That includes, basically, every
5516C<BEGIN> block executed directly or indirectly from during the
5517compile-time of the top-level program.
5518
5519=end original
5520
5521これはコンパイル時にグローバルです。
5522これは基本的に、直接実行されたり、トップレベルプログラムの
5523コンパイル時の間に間接的に実行される全ての C<BEGIN> です。
5524
5525=begin original
5526
5527This phase is not called "BEGIN" to avoid confusion with
5528C<BEGIN>-blocks, as those are executed during compile-time of any
5529compilation unit, not just the top-level program. A new, localised
5530compile-time entered at run-time, for example by constructs as
5531C<eval "use SomeModule"> are not global interpreter phases, and
5532therefore aren't reflected by C<${^GLOBAL_PHASE}>.
5533
5534=end original
5535
5536C<BEGIN> ブロックとの混乱を避けるために、このフェーズの名前は "BEGIN" では
5537ありません; これらは単にトップレベルプログラムではなく、任意のコンパイル
5538ユニットのコンパイル中に実行されます。
5539例えば C<eval "use SomeModule"> のように、実行時に入った
5540新しいローカル化されたコンパイル時はグローバルなインタプリタフェーズではなく、
5541従って C<${^GLOBAL_PHASE}> に反映されません。
5542
5543=item CHECK
5544
5545=begin original
5546
5547Execution of any C<CHECK> blocks.
5548
5549=end original
5550
5551C<CHECK> ブロックの実行。
5552
5553=item INIT
5554
5555=begin original
5556
5557Similar to "CHECK", but for C<INIT>-blocks, not C<CHECK> blocks.
5558
5559=end original
5560
5561"CHECK" と似ていますが、C<CHECK> ブロックではなく C<INIT> ブロック。
5562
5563=item RUN
5564
5565=begin original
5566
5567The main run-time, i.e. the execution of C<PL_main_root>.
5568
5569=end original
5570
5571メインの実行; つまり C<PL_main_root> の実行。
5572
5573=item END
5574
5575=begin original
5576
5577Execution of any C<END> blocks.
5578
5579=end original
5580
5581C<END> ブロックの実行。
5582
5583=item DESTRUCT
5584
5585=begin original
5586
5587Global destruction.
5588
5589=end original
5590
5591グローバルなデストラクタ。
5592
5593=back
5594
5595=begin original
5596
5597Also note that there's no value for UNITCHECK-blocks. That's because
5598those are run for each compilation unit individually, and therefore is
5599not a global interpreter phase.
5600
5601=end original
5602
5603また、UNITCHECK ブロックのための値はないことに注意してください。
5604なぜなら、これらはコンパイルユニット毎に独立に実行され、従って
5605グローバルなインタプリタフェーズではないからです。
5606
5607=begin original
5608
5609Not every program has to go through each of the possible phases, but
5610transition from one phase to another can only happen in the order
5611described in the above list.
5612
5613=end original
5614
5615全てのプログラムが可能な全てのフェーズを通らなければならないわけでは
5616ありませんが、あるフェーズから他のフェーズへの移行は上述の
5617順でのみ起こります。
5618
5619=begin original
5620
5621An example of all of the phases Perl code can see:
5622
5623=end original
5624
5625Perl コードの全てのフェーズを見る例です:
5626
5627 BEGIN { print "compile-time: ${^GLOBAL_PHASE}\n" }
5628
5629 INIT { print "init-time: ${^GLOBAL_PHASE}\n" }
5630
5631 CHECK { print "check-time: ${^GLOBAL_PHASE}\n" }
5632
5633 {
5634 package Print::Phase;
5635
5636 sub new {
5637 my ($class, $time) = @_;
5638 return bless \$time, $class;
5639 }
5640
5641 sub DESTROY {
5642 my $self = shift;
5643 print "$$self: ${^GLOBAL_PHASE}\n";
5644 }
5645 }
5646
5647 print "run-time: ${^GLOBAL_PHASE}\n";
5648
5649 my $runtime = Print::Phase->new(
5650 "lexical variables are garbage collected before END"
5651 );
5652
5653 END { print "end-time: ${^GLOBAL_PHASE}\n" }
5654
5655 our $destruct = Print::Phase->new(
5656 "package variables are garbage collected after END"
5657 );
5658
5659=begin original
5660
5661This will print out
5662
5663=end original
5664
5665これは以下のものを出力します:
5666
5667 compile-time: START
5668 check-time: CHECK
5669 init-time: INIT
5670 run-time: RUN
5671 lexical variables are garbage collected before END: RUN
5672 end-time: END
5673 package variables are garbage collected after END: DESTRUCT
5674
5675=begin original
5676
5677This variable was added in Perl 5.14.0.
5678
5679=end original
5680
5681この変数は Perl 5.14.0 で追加されました。
5682
5683=item $^H
5684X<$^H>
5685
5686=begin original
5687
5688WARNING: This variable is strictly for
5689internal use only. Its availability,
5690behavior, and contents are subject to change without notice.
5691
5692=end original
5693
5694警告: この変数は厳密に内部使用に限定されます。
5695その可用性、挙動、内容は告知なく変更される可能性があります。
5696
5697=begin original
5698
5699This variable contains compile-time hints for the Perl interpreter. At the
5700end of compilation of a BLOCK the value of this variable is restored to the
5701value when the interpreter started to compile the BLOCK.
5702
5703=end original
5704
5705この変数には Perl インタプリタのコンパイル時のヒントが入ります。
5706BLOCK のコンパイル終了時に、この変数の値は
5707インタプリタが BLOCK のコンパイルを開始した時の値に戻されます。
5708
5709=begin original
5710
5711Each time a statement completes being compiled, the current value of
5712C<$^H> is stored with that statement, and can later be retrieved via
5713C<(caller($level))[8]>. See L<perlfunc/caller EXPR>.
5714
5715=end original
5716
5717文のコンパイルが完了する毎に、C<$^H> の現在の値が文と共に
5718保管され、C<(caller($level))[8]> として後で取得できます。
5719L<perlfunc/caller EXPR> を参照してください。
5720
5721=begin original
5722
5723When perl begins to parse any block construct that provides a lexical scope
5724(e.g., eval body, required file, subroutine body, loop body, or conditional
5725block), the existing value of C<$^H> is saved, but its value is left unchanged.
5726When the compilation of the block is completed, it regains the saved value.
5727Between the points where its value is saved and restored, code that
5728executes within BEGIN blocks is free to change the value of C<$^H>.
5729
5730=end original
5731
5732Perl がレキシカルスコープを持つブロック構造(eval の中身、required された
5733ファイル、サブルーチンの中身、loop の中身、条件付きブロック)の
5734パースを開始するとき、現在の C<$^H> の値は保存されますが、値は
5735変更されません。
5736ブロックのコンパイルが終わると、保存された値が戻されます。
5737値の保存と回復の間の地点で、BEGIN ブロックの中で実行されるコードは自由に
5738C<$^H> の値を変更できます。
5739
5740=begin original
5741
5742This behavior provides the semantic of lexical scoping, and is used in,
5743for instance, the C<use strict> pragma.
5744
5745=end original
5746
5747この振る舞いはレキシカルスコープを持ち、その中で使えます; 例としては
5748C<use strict> があります。
5749
5750=begin original
5751
5752The contents should be an integer; different bits of it are used for
5753different pragmatic flags. Here's an example:
5754
5755=end original
5756
5757内容は整数であるべきです; ビット毎に異なるプラグマフラグとして使われます。
5758以下は例です:
5759
5760 sub add_100 { $^H |= 0x100 }
5761
5762 sub foo {
5763 BEGIN { add_100() }
5764 bar->baz($boon);
5765 }
5766
5767=begin original
5768
5769Consider what happens during execution of the BEGIN block. At this point
5770the BEGIN block has already been compiled, but the body of C<foo()> is still
5771being compiled. The new value of C<$^H>
5772will therefore be visible only while
5773the body of C<foo()> is being compiled.
5774
5775=end original
5776
5777BEGIN ブロックの実行中に起こることを考えてみます。
5778この時点で BEGIN ブロックは既にコンパイルされていますが、
5779C<foo()> の中身はまだコンパイル中です。
5780従って C<$^H> の新しい値は C<foo()> の中身がコンパイル中にのみ
5781見ることが出来ます。
5782
5783=begin original
5784
5785Substitution of C<BEGIN { add_100() }> block with:
5786
5787=end original
5788
5789C<BEGIN { add_100() }> ブロックを以下のように変更すると:
5790
5791 BEGIN { require strict; strict->import('vars') }
5792
5793=begin original
5794
5795demonstrates how C<use strict 'vars'> is implemented. Here's a conditional
5796version of the same lexical pragma:
5797
5798=end original
5799
5800どのように C<use strict 'vars'> が実装されているかがわかります。
5801以下は同じレキシカルプラグマの条件付き版です:
5802
5803 BEGIN {
5804 require strict; strict->import('vars') if $condition
5805 }
5806
5807=begin original
5808
5809This variable was added in Perl 5.003.
5810
5811=end original
5812
5813この変数は Perl 5.003 で追加されました。
5814
5815=item %^H
5816X<%^H>
5817
5818=begin original
5819
5820The C<%^H> hash provides the same scoping semantics as L<C<$^H>|/$^H>. This
5821makes it useful for implementing lexically scoped pragmas. See L<perlpragma>.
5822All the entries are stringified when accessed at runtime, so only simple values
5823can be accommodated. This means no references to objects, for example.
5824
5825=end original
5826
5827C<%^H> ハッシュは L<C<$^H>|/$^H> と同じスコープの意味論を持ちます。
5828これはレキシカルスコープを持つプラグマを実装するのに便利です。
5829L<perlpragma> を参照してください。
5830実行時にアクセスされると全てのエントリは文字列化されるので、
5831単純な値のみに対応します。
5832これは、例えばオブジェクトへのリファレンスはないということです。
5833
5834=begin original
5835
5836Each time a statement completes being compiled, the current value of
5837C<%^H> is stored with that statement, and can later be retrieved via
5838C<(caller($level))[10]>. See L<perlfunc/caller EXPR>.
5839
5840=end original
5841
5842文のコンパイルが完了する毎に、C<%^H> の現在の値が文と共に
5843保管され、C<(caller($level))[10]> として後で取得できます。
5844L<perlfunc/caller EXPR> を参照してください。
5845
5846=begin original
5847
5848When putting items into C<%^H>, in order to avoid conflicting with other
5849users of the hash there is a convention regarding which keys to use.
5850A module should use only keys that begin with the module's name (the
5851name of its main package) and a "/" character. For example, a module
5852C<Foo::Bar> should use keys such as C<Foo::Bar/baz>.
5853
5854=end original
5855
5856C<%^H> に追加するとき、他のハッシュのユーザーとの衝突を回避するために、
5857キーの使い方に関する慣習があります。
5858モジュールはモジュールの名前(主なパッケージの名前)と "/" 文字で始まる
5859キーのみを使うべきです。
5860例えば、モジュール C<Foo::Bar> は C<Foo::Bar/baz> のようなキーを
5861使うべきです。
5862
5863=begin original
5864
5865This variable was added in Perl v5.6.0.
5866
5867=end original
5868
5869この変数は Perl v5.6.0 で追加されました。
5870
5871=item ${^OPEN}
5872X<${^OPEN}>
5873
5874=begin original
5875
5876An internal variable used by L<PerlIO>. A string in two parts, separated
5877by a C<\0> byte, the first part describes the input layers, the second
5878part describes the output layers.
5879
5880=end original
5881
5882L<PerlIO> で使われる内部変数です。
5883文字列は C<\0> で分割された二つの部分からなり、前半は入力層を、
5884後半は出力層を示します。
5885
5886=begin original
5887
5888This is the mechanism that applies the lexical effects of the L<open>
5889pragma, and the main program scope effects of the C<io> or C<D> options
5890for the L<-C command-line switch|perlrun/-C [I<numberE<sol>list>]> and
5891L<PERL_UNICODE environment variable|perlrun/PERL_UNICODE>.
5892
5893=end original
5894
5895これは L<open> プラグマおよび、C<io> や
5896L<-C コマンドラインオプション|perlrun/-C [I<numberE<sol>list>]> と
5897L<PERL_UNICODE 環境変数|perlrun/PERL_UNICODE> の C<D> オプションの
5898メインプログラムスコープにレキシカルな効果を適用するための機構です。
5899
5900=begin original
5901
5902The functions C<accept()>, C<open()>, C<pipe()>, C<readpipe()> (as well
5903as the related C<qx> and C<`STRING`> operators), C<socket()>,
5904C<socketpair()>, and C<sysopen()> are affected by the lexical value of
5905this variable. The implicit L</ARGV> handle opened by C<readline()> (or
5906the related C<< <> >> and C<<< <<>> >>> operators) on passed filenames is
5907also affected (but not if it opens C<STDIN>). If this variable is not
5908set, these functions will set the default layers as described in
5909L<PerlIO/Defaults and how to override them>.
5910
5911=end original
5912
5913C<accept()>, C<open()>, C<pipe()>, C<readpipe()> (および関連する
5914C<qx> と C<`STRING`> 演算子), C<socket()>,
5915C<socketpair()>, C<sysopen()> 関数は、この変数のレキシカルな値に
5916影響を受けます。
5917C<readline()> (や関連する C<< <> >> と C<<< <<>> >>> 演算子) に
5918ファイル名を渡すことによって開かれた暗黙の L</ARGV> も影響を受けます
5919(しかし C<STDIN> を開いている場合は影響を受けません)。
5920この変数が設定されていない場合、これらの関数は
5921L<PerlIO/Defaults and how to override them> で記述されている
5922デフォルト層が設定されます。
5923
5924=begin original
5925
5926C<open()> ignores this variable (and the default layers) when called with
59273 arguments and explicit layers are specified. Indirect calls to these
5928functions via modules like L<IO::Handle> are not affected as they occur
5929in a different lexical scope. Directory handles such as opened by
5930C<opendir()> are not currently affected.
5931
5932=end original
5933
5934C<open()> は、3 引数で呼び出され、明示的な層が指定された場合は
5935この変数(およびデフォルト層)を無視します。
5936L<IO::Handle> のようなモジュール経由でのこれらの関数の間接的な呼び出しは
5937影響を受けません; これらは異なったレキシカルスコープで起きるからです。
5938C<opendir()> で開かれたようなディレクトリハンドルは現在の所
5939影響を受けません。
5940
5941=begin original
5942
5943This variable was added in Perl v5.8.0.
5944
5945=end original
5946
5947この変数は Perl v5.8.0 で追加されました。
5948
5949=item $PERLDB
5950
5951=item $^P
5952X<$^P> X<$PERLDB>
5953
5954=begin original
5955
5956The internal variable for debugging support. The meanings of the
5957various bits are subject to change, but currently indicate:
5958
5959=end original
5960
5961デバッグ機能のための内部変数です。
5962それぞれのビットの意味は変わるかもしれませんが、
5963現在のところは以下の通りです:
5964
5965=over 6
5966
5967=item 0x01
5968
5969=begin original
5970
5971Debug subroutine enter/exit.
5972
5973=end original
5974
5975サブルーチンの出入りをデバッグします。
5976
5977=item 0x02
5978
5979=begin original
5980
5981Line-by-line debugging. Causes C<DB::DB()> subroutine to be called for
5982each statement executed. Also causes saving source code lines (like
59830x400).
5984
5985=end original
5986
5987行毎にデバッグします。
5988各行を実行する毎に C<DB::DB()> サブルーチンを呼び出します。
5989さらに、(0x400 のように) ソースコードを保存します。
5990
5991=item 0x04
5992
5993=begin original
5994
5995Switch off optimizations.
5996
5997=end original
5998
5999最適化を行いません。
6000
6001=item 0x08
6002
6003=begin original
6004
6005Preserve more data for future interactive inspections.
6006
6007=end original
6008
6009将来の対話的な検査のためにより多くのデータを保存します。
6010
6011=item 0x10
6012
6013=begin original
6014
6015Keep info about source lines on which a subroutine is defined.
6016
6017=end original
6018
6019サブルーチンが定義されたソース行に関する情報を保持します。
6020
6021=item 0x20
6022
6023=begin original
6024
6025Start with single-step on.
6026
6027=end original
6028
6029シングルステップ実行で開始します。
6030
6031=item 0x40
6032
6033=begin original
6034
6035Use subroutine address instead of name when reporting.
6036
6037=end original
6038
6039報告時にサブルーチン名でなくサブルーチンのアドレスを使います。
6040
6041=item 0x80
6042
6043=begin original
6044
6045Report C<goto &subroutine> as well.
6046
6047=end original
6048
6049C<goto &subroutine> も同様に報告します。
6050
6051=item 0x100
6052
6053=begin original
6054
6055Provide informative "file" names for evals based on the place they were compiled.
6056
6057=end original
6058
6059eval に対して、コンパイルされた位置を元にした「ファイル」名を提供します。
6060
6061=item 0x200
6062
6063=begin original
6064
6065Provide informative names to anonymous subroutines based on the place they
6066were compiled.
6067
6068=end original
6069
6070無名サブルーチンに対して、
6071コンパイルされた位置を基にした参考名を提供します。
6072
6073=item 0x400
6074
6075=begin original
6076
6077Save source code lines into C<@{"_<$filename"}>.
6078
6079=end original
6080
6081ソースコードの行数を C<@{"_<$filename"}> に保存します。
6082
6083=item 0x800
6084
6085=begin original
6086
6087When saving source, include evals that generate no subroutines.
6088
6089=end original
6090
6091ソースを保存するときに、サブルーチンがない eval を含みます。
6092
6093=item 0x1000
6094
6095=begin original
6096
6097When saving source, include source that did not compile.
6098
6099=end original
6100
6101ソースを保存するときに、コンパイルしていないソースを含みます。
6102
6103=back
6104
6105=begin original
6106
6107Some bits may be relevant at compile-time only, some at
6108run-time only. This is a new mechanism and the details may change.
6109See also L<perldebguts>.
6110
6111=end original
6112
6113一部のビットはコンパイル時にのみまたは実行時にのみ意味があります。
6114これは新しい機構であり、詳細は変更されるかもしれません。
6115L<perldebguts> も参照してください。
6116
6117=item ${^TAINT}
6118X<${^TAINT}>
6119
6120=begin original
6121
6122Reflects if taint mode is on or off. 1 for on (the program was run with
6123B<-T>), 0 for off, -1 when only taint warnings are enabled (i.e. with
6124B<-t> or B<-TU>).
6125
6126=end original
6127
6128汚染検査モードのオン・オフを反映します。
61291 はオン(プログラムは B<-T> 付きで実行されている)、0 はオフ、-1 は汚染
6130警告のみが有効になっている(つまり B<-t> か B<-TU>)ことを意味します。
6131
6132=begin original
6133
6134Note: if your perl was built without taint support (see L<perlsec>),
6135then C<${^TAINT}> will always be 0, even if the program was run with B<-T>).
6136
6137=end original
6138
6139注意: perl が汚染チェック対応 (L<perlsec> 参照) なしでビルドされている場合、
6140たとえプログラムが B<-T> 付きで実行されていても、
6141C<${^TAINT}> は常に 0 です。
6142
6143=begin original
6144
6145This variable is read-only.
6146
6147=end original
6148
6149この変数は読み込み専用です。
6150
6151=begin original
6152
6153This variable was added in Perl v5.8.0.
6154
6155=end original
6156
6157この変数は Perl v5.8.0 で追加されました。
6158
6159=item ${^SAFE_LOCALES}
6160X<${^SAFE_LOCALES}>
6161
6162=begin original
6163
6164Reflects if safe locale operations are available to this perl (when the
6165value is 1) or not (the value is 0). This variable is always 1 if the
6166perl has been compiled without threads. It is also 1 if this perl is
6167using thread-safe locale operations. Note that an individual thread may
6168choose to use the global locale (generally unsafe) by calling
6169L<perlapi/switch_to_global_locale>. This variable currently is still
6170set to 1 in such threads.
6171
6172=end original
6173
6174この perl で安全なロケール操作が利用可能 (値が 1 の場合) かそうでない
6175(値が 0 の場合) かを反映します。
6176この変数は、perl がスレッドなしでコンパイルされている場合は常に 1 です。
6177また、perl がスレッドセーフなロケール操作を使っている場合は 1 です。
6178個々のスレッドは L<perlapi/switch_to_global_locale> を呼び出すことで
6179(一般的にはスレッドセーフでない) グローバルなロケールを使うことを
6180選ぶかも知れないことに注意してください。
6181この変数はそのようなスレッドでも 1 のままです。
6182
6183=begin original
6184
6185This variable is read-only.
6186
6187=end original
6188
6189この変数は読み込み専用です。
6190
6191=begin original
6192
6193This variable was added in Perl v5.28.0.
6194
6195=end original
6196
6197この変数は Perl v5.28.0 で追加されました。
6198
6199=item ${^UNICODE}
6200X<${^UNICODE}>
6201
6202=begin original
6203
6204Reflects certain Unicode settings of Perl. See
6205L<perlrun|perlrun/-C [numberE<sol>list]> documentation for the C<-C>
6206switch for more information about the possible values.
6207
6208=end original
6209
6210Perl のいくつかの Unicode 設定を反映します。
6211設定できる値に関するさらなる情報については
6212L<perlrun|perlrun/-C [numberE<sol>list]> の C<-C> オプションを
6213参照してください。
6214
6215=begin original
6216
6217This variable is set during Perl startup and is thereafter read-only.
6218
6219=end original
6220
6221この変数は Perl 起動時に設定され、その後は読み込み専用です。
6222
6223=begin original
6224
6225This variable was added in Perl v5.8.2.
6226
6227=end original
6228
6229この変数は Perl v5.8.2 で追加されました。
6230
6231=item ${^UTF8CACHE}
6232X<${^UTF8CACHE}>
6233
6234=begin original
6235
6236This variable controls the state of the internal UTF-8 offset caching code.
62371 for on (the default), 0 for off, -1 to debug the caching code by checking
6238all its results against linear scans, and panicking on any discrepancy.
6239
6240=end original
6241
6242この変数は内部 UTF-8 オフセットキャッシュコードの状態を制御します。
62431 はオン(デフォルト)、0 はオフ、-1 は全ての結果を線形走査と比較して、
6244矛盾があれば異常終了する、という形でキャッシュコードをデバッグします。
6245
6246=begin original
6247
6248This variable was added in Perl v5.8.9. It is subject to change or
6249removal without notice, but is currently used to avoid recalculating the
6250boundaries of multi-byte UTF-8-encoded characters.
6251
6252=end original
6253
6254この変数は Perl v5.8.9 で追加されました。
6255これは予告なく変更されたり削除されたりするかもしれませんが、現在のところ
6256複数バイト UTF-8 エンコード文字の境界の再計算を避けるために使われます。
6257
6258=item ${^UTF8LOCALE}
6259X<${^UTF8LOCALE}>
6260
6261=begin original
6262
6263This variable indicates whether a UTF-8 locale was detected by perl at
6264startup. This information is used by perl when it's in
6265adjust-utf8ness-to-locale mode (as when run with the C<-CL> command-line
6266switch); see L<perlrun|perlrun/-C [numberE<sol>list]> for more info on
6267this.
6268
6269=end original
6270
6271この変数は、起動時に perl によって UTF-8 ロケールが検出されたかどうかを
6272示します。
6273この情報は(C<-CL> コマンドラインスイッチで起動されることによって)
6274「utf8 性をロケールに合わせる」モードのときに perl によって使われます;
6275これに関するさらなる情報は
6276L<perlrun|perlrun/-C [numberE<sol>list]> を参照してください。
6277
6278=begin original
6279
6280This variable was added in Perl v5.8.8.
6281
6282=end original
6283
6284この変数は Perl v5.8.8 で追加されました。
6285
6286=back
6287
46966288=head2 Deprecated and removed variables
46976289
46986290(非推奨および削除された変数)
46996291
47006292=begin original
47016293
47026294Deprecating a variable announces the intent of the perl maintainers to
4703eventually remove the variable from the langauge. It may still be
6295eventually remove the variable from the language. It may still be
4704available despite its status. Using a deprecated variable triggers
6296available despite its status. Using a deprecated variable triggers
47056297a warning.
47066298
47076299=end original
47086300
47096301非推奨となった変数は、perl のメンテナが最終的にこの変数を
47106302削除するということを意図して通知されます。
47116303その状態にも関わらず、まだ利用可能です。
47126304非推奨となった変数を使うと警告が出ます。
47136305
47146306=begin original
47156307
47166308Once a variable is removed, its use triggers an error telling you
47176309the variable is unsupported.
47186310
47196311=end original
47206312
47216313変数が削除された後で変数を使うと、この変数が非対応となったことを
47226314知らせるエラーが出ます。
47236315
47246316=begin original
47256317
47266318See L<perldiag> for details about error messages.
47276319
47286320=end original
47296321
47306322エラーメッセージの詳細については L<perldiag> を参照してください。
47316323
47326324=over 8
47336325
4734=item $OFMT
4735
47366326=item $#
4737X<$#> X<$OFMT>
6327X<$#>
47386328
47396329=begin original
47406330
4741C<$#> was a variable that you could be use to format printed numbers.
6331C<$#> was a variable that could be used to format printed numbers.
4742After a deprecation cycle, its magic was removed in Perl 5.10 and
6332After a deprecation cycle, its magic was removed in Perl v5.10.0 and
47436333using it now triggers a warning: C<$# is no longer supported>.
47446334
47456335=end original
47466336
47476337C<$#> は、表示番号をフォーマットするために使われていました。
4748非推奨化の後、このマジックは Perl 5.10 で取り除かれ、警告を
6338非推奨化の後、このマジックは Perl v5.10.0 で取り除かれ、警告を
47496339引き起こします: C<$# is no longer supported>.
47506340
47516341=begin original
47526342
47536343This is not the sigil you use in front of an array name to get the
4754last index, like C<$#array>. That's still how you get the last index
6344last index, like C<$#array>. That's still how you get the last index
4755of an array in Perl. The two have nothing to do with each other.
6345of an array in Perl. The two have nothing to do with each other.
47566346
47576347=end original
47586348
47596349これは C<$#array> のように最後のインデックスを得るために配列名の前に付ける
47606350印ではありません。
47616351これは今でも Perl で配列の最後のインデックスを得る方法です。
47626352これら二つには互いに何の関係もありません。
47636353
47646354=begin original
47656355
47666356Deprecated in Perl 5.
47676357
47686358=end original
47696359
47706360Perl 5 で非推奨となりました。
47716361
47726362=begin original
47736363
4774Removed in Perl 5.10.
6364Removed in Perl v5.10.0.
47756365
47766366=end original
47776367
4778Perl 5.10 で削除されました。
6368Perl v5.10.0 で削除されました。
47796369
47806370=item $*
47816371X<$*>
47826372
47836373=begin original
47846374
47856375C<$*> was a variable that you could use to enable multiline matching.
4786After a deprecation cycle, its magic was removed in Perl 5.10.
6376After a deprecation cycle, its magic was removed in Perl v5.10.0.
47876377Using it now triggers a warning: C<$* is no longer supported>.
47886378You should use the C</s> and C</m> regexp modifiers instead.
47896379
47906380=end original
47916381
47926382C<$*> は複数行マッチングを有効にするために使われていた変数です。
4793非推奨化の後、このマジックは Perl 5.10 で削除されました。
6383非推奨化の後、このマジックは Perl v5.10.0 で削除されました。
47946384これを使うと警告を引き起こします: C<$* is no longer supported>。
47956385代わりに C</s> と C</m> の正規表現修飾子を使うべきです。
47966386
47976387=begin original
47986388
47996389Deprecated in Perl 5.
48006390
48016391=end original
48026392
48036393Perl 5 で非推奨となりました。
48046394
48056395=begin original
48066396
4807Removed in Perl 5.10.
6397Removed in Perl v5.10.0.
48086398
48096399=end original
48106400
4811Perl 5.10 で削除されました。
6401Perl v5.10.0 で削除されました。
48126402
4813=item $ARRAY_BASE
4814
48156403=item $[
4816X<$[> X<$ARRAY_BASE>
6404X<$[>
48176405
48186406=begin original
48196407
48206408This variable stores the index of the first element in an array, and
4821of the first character in a substring. The default is 0, but you could
6409of the first character in a substring. The default is 0, but you could
48226410theoretically set it to 1 to make Perl behave more like B<awk> (or Fortran)
48236411when subscripting and when evaluating the index() and substr() functions.
48246412
48256413=end original
48266414
48276415この変数は配列の最初の要素や、文字列の最初の文字のインデックスを
48286416保管します。
48296417デフォルトは 0 ですが、理論的には、index() 関数や
48306418substr() 関数を評価するときに、Perl の動作をより B<awk>
48316419(や Fortran) に近づけるため、1 に設定することもできます。
48326420
48336421=begin original
48346422
48356423As of release 5 of Perl, assignment to C<$[> is treated as a compiler
48366424directive, and cannot influence the behavior of any other file.
48376425(That's why you can only assign compile-time constants to it.)
48386426Its use is highly discouraged.
48396427
48406428=end original
48416429
48426430Perl 5 からは C<$[> への代入は、コンパイラ指示子として扱われ、
48436431他のファイルの動作に影響を与えることがなくなりました。
48446432(これが、コンパイル時定数しか代入できない理由です。)
48456433この変数の使用は非推奨です。
48466434
48476435=begin original
48486436
4849Prior to Perl 5.10, assignment to C<$[> could be seen from outer lexical
6437Prior to Perl v5.10.0, assignment to C<$[> could be seen from outer lexical
48506438scopes in the same file, unlike other compile-time directives (such as
4851L<strict>). Using local() on it would bind its value strictly to a lexical
6439L<strict>). Using local() on it would bind its value strictly to a lexical
4852block. Now it is always lexically scoped.
6440block. Now it is always lexically scoped.
48536441
48546442=end original
48556443
4856Perl 5.10 より前では、C<$[> は(L<strict> のような)その他のコンパイル時
6444Perl v5.10.0 より前では、C<$[> は(L<strict> のような)その他のコンパイル時
48576445指示子と異なり、同じファイルのレキシカルスコープの外側から見ることが
48586446出来ていました。
48596447これに local() を使うとこの値を厳密にレキシカルスコープの内側に限定します。
48606448今では常にレキシカルスコープを持ちます。
48616449
48626450=begin original
48636451
6452As of Perl v5.16.0, it is implemented by the L<arybase> module.
6453
6454=end original
6455
6456Perl v5.16.0 から、これは L<arybase> モジュールで実装されています。
6457
6458=begin original
6459
6460As of Perl v5.30.0, or under C<use v5.16>, or C<no feature "array_base">,
6461C<$[> no longer has any effect, and always contains 0.
6462Assigning 0 to it is permitted, but any other value will produce an error.
6463
6464=end original
6465
6466Perl v5.30.0 以降か、C<use v5.16> または C<no feature "array_base"> の基では、
6467C<$[> はもはや何の効果もなく、常に 0 が入っています。
6468これに 0 を代入することは許されますが、それ以外の値はエラーを引き起こします。
6469
6470=begin original
6471
48646472Mnemonic: [ begins subscripts.
48656473
48666474=end original
48676475
48686476記憶法: [ は添え字付けの始め。
48696477
48706478=begin original
48716479
4872Deprecated in Perl 5.12.
6480Deprecated in Perl v5.12.0.
48736481
48746482=end original
48756483
4876Perl 5.12 で非推奨となりました。
6484Perl v5.12.0 で非推奨となりました。
48776485
4878=item $OLD_PERL_VERSION
6486=item ${^ENCODING}
6487X<${^ENCODING}>
48796488
4880=item $]
6489=begin original
4881X<$]> X<$OLD_PERL_VERSION>
48826490
6491This variable is no longer supported.
6492
6493=end original
6494
6495この変数はもはや対応していません。
6496
48836497=begin original
48846498
4885See C<$^V> for a more modern representation of the Perl version that allows
6499It used to hold the I<object reference> to the C<Encode> object that was
4886accurate string comparisons.
6500used to convert the source code to Unicode.
48876501
48886502=end original
48896503
4890正確な文字列比較ができる、より近代的な Perl バージョンの表現ついては
6504これはソースコードを Unicode に変換するために使われる
4891C<$^V> を参照してください。
6505C<Encode> オブジェクトへの I<オブジェクトリファレンス> 保持していました
48926506
48936507=begin original
48946508
4895The version + patchlevel / 1000 of the Perl interpreter. This variable
6509Its purpose was to allow your non-ASCII Perl
4896can be used to determine whether the Perl interpreter executing a
6510scripts not to have to be written in UTF-8; this was
4897script is in the right range of versions:
6511useful before editors that worked on UTF-8 encoded text were common, but
6512that was long ago. It caused problems, such as affecting the operation
6513of other modules that weren't expecting it, causing general mayhem.
48986514
48996515=end original
49006516
4901Perl インタプタの version + patchlevel / 1000 が返されま
6517この目的は、非 ASCII Perl スクプトを UTF-8 で書く必要をなくためでした;
4902クリプの最初、そのスクリプトを実行していインプリタのバージョン
6518これは UTF-8 エンコードされたテキストで動作すエディタが一般的になる前は
4903適切な範囲内にあるかを調べるといたこきます。
6519有用でしたがそれはずっとです。
4904例:
6520これは、想定してない他のモジュールの操作に影響を与えるような問題を引き起こし、
6521一般的には破壊的です。
49056522
4906 warn "No checksumming!\n" if $] < 3.019;
6523=begin original
49076524
6525If you need something like this functionality, it is recommended that use
6526you a simple source filter, such as L<Filter::Encoding>.
6527
6528=end original
6529
6530この機能のような何かが必要な場合は、L<Filter::Encoding> のような
6531単純なソースフィルタを使うことを勧めます。
6532
49086533=begin original
49096534
4910The floating point representation can sometimes lead to inaccurate
6535If you are coming here because code of yours is being adversely affected
4911numeric comparisons.
6536by someone's use of this variable, you can usually work around it by
6537doing this:
49126538
49136539=end original
49146540
4915浮動小数点表現は数値比較不正確なることります。
6541あなたここ来た理由が、誰かがの変数を使うこなたのコードが
4916文字列比較が使える新しい Perl バージョン表現方法ある C<$^V> を
6542意図せずに影響を受けたためなら、通常は次ようにして回避きます:
4917参照して下さい。
49186543
6544 local ${^ENCODING};
6545
49196546=begin original
49206547
4921See also the documentation of C<use VERSION> and C<require VERSION>
6548near the beginning of the functions that are getting broken. This
4922for a convenient way to fail if the running Perl interpreter is too old.
6549undefines the variable during the scope of execution of the including
6550function.
49236551
49246552=end original
49256553
4926実行する Perl インタプリタが古すぎる場合終了る便利な方法に
6554これを壊れてしまった関数の先頭付近書きま
4927ついては C<use VERSION> と C<require VERSION> ドキュメントも
6555これにより、こ関数を含むスコープを実行する間この変数を未定義にします。
4928参照して下さい。
49296556
49306557=begin original
49316558
4932Mnemonic: Is this version of perl in the right bracket?
6559This variable was added in Perl 5.8.2 and removed in 5.26.0.
6560Setting it to anything other than C<undef> was made fatal in Perl 5.28.0.
49336561
49346562=end original
49356563
4936記憶法: Perl のバージョンは正しい範囲 (right bracket) にあるか
6564この変数は Perl 5.8.2 で追加され5.26.0 で削除されました
6565Perl 5.28.0 から、これに C<undef> 以外の値を設定すると致命的エラーになります。
49376566
6567=item ${^WIN32_SLOPPY_STAT}
6568X<${^WIN32_SLOPPY_STAT}> X<sitecustomize> X<sitecustomize.pl>
6569
49386570=begin original
49396571
4940Deprecated in Perl 5.6.
6572This variable no longer has any function.
49416573
49426574=end original
49436575
4944Perl 5.6 で非推奨となりました
6576この変数はもはや何の機能もありません
49456577
6578=begin original
6579
6580This variable was added in Perl v5.10.0 and removed in Perl v5.34.0.
6581
6582=end original
6583
6584この変数は Perl v5.10.0 で追加され、Perl v5.34.0 で削除されました。
6585
49466586=back
49476587
6588=cut
6589
49486590=begin meta
49496591
49506592Translate: 吉村 寿人 <JAE00534@niftyserve.or.jp> (5.000)
49516593Update: Kentaro Shirakata <argrath@ub32.org> (5.6.1-)
6594Status: completed
49526595
49536596=end meta
4954
4955=cut