perlvar > 5.30.0 との差分

perlvar 5.30.0 と 5.28.0 の差分

11
22=encoding euc-jp
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
2222Variable 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
2626C<::> or C<'>. In this case, the part before the last C<::> or
2727C<'> is taken to be a I<package qualifier>; see L<perlmod>.
2828A Unicode letter that is not ASCII is not considered to be a letter
2929unless S<C<"use utf8">> is in effect, and somewhat more complicated
3030rules apply; see L<perldata/Identifier parsing> for details.
3131
3232=end original
3333
3434Perl の変数名は様々な形があります。
3535通常、変数名は英文字か下線で始まらなければならず、
3636任意の長さ(内部制限の 251 文字まで)を取ることができ、
3737英文字、数字、下線、特別な文字列である C<::> と C<'> を含むことができます。
3838この場合、最後の C<::> または C<'> の前は I<パッケージ限定子> として
3939扱われます; L<perlmod> を参照して下さい。
4040ASCII ではない Unicode 文字は、S<C<"use utf8">> が有効でない限り
4141文字として扱われません; そしていくらかより複雑な規則が適用されます;
4242詳しくは L<perldata/Identifier parsing> を参照してください。
4343
4444=begin original
4545
4646Perl variable names may also be a sequence of digits, a single
4747punctuation character, or the two-character sequence: C<^> (caret or
4848CIRCUMFLEX ACCENT) followed by any one of the characters C<[][A-Z^_?\]>.
4949These names are all reserved for
5050special uses by Perl; for example, the all-digits names are used
5151to hold data captured by backreferences after a regular expression
5252match.
5353
5454=end original
5555
5656Perl の変数は、数字の列または一文字の句読点文字、2 文字並び(
5757C<^> (キャレット、CIRCUMFLEX ACCENT) に引き続いて C<[][A-Z^_?\]> の文字の一つ)
5858の場合もあります。
5959これらの名前は全て Perl によって特別な用途のために予約されています;
6060例えば、全て数字の名前は正規表現マッチの後の後方参照のデータを
6161保持するために用いられます。
6262
6363=begin original
6464
6565Since Perl v5.6.0, Perl variable names may also be alphanumeric strings
6666preceded by a caret. These must all be written in the form C<${^Foo}>;
6767the braces are not optional. C<${^Foo}> denotes the scalar variable
6868whose name is considered to be a control-C<F> followed by two C<o>'s.
6969These variables are
7070reserved for future special uses by Perl, except for the ones that
7171begin with C<^_> (caret-underscore). No
7272name that begins with C<^_> will acquire a special
7373meaning in any future version of Perl; such names may therefore be
7474used safely in programs. C<$^_> itself, however, I<is> reserved.
7575
7676=end original
7777
7878Perl v5.6.0 から、キャレットが前置された、英数字からなる文字列の変数名も
7979使えます。
8080これらは全て C<${^Foo}> の形で書かれなければなりません;
8181括弧は必須です。
8282C<${^Foo}> はコントロール-C<F> の後に二つ C<o> が続く名前を持つ
8383スカラ変数と考えられます。
8484これらの変数は Perl によって特別な用途のために予約されていますが、
8585C<^_> (キャレット-下線)で始まるものは例外です。
8686C<^_> で始まる名前は Perl の将来のバージョンで特別な意味を
8787持つことはありません; 従ってこれらの名前はプログラム中で安全に使用できます。
8888但し、C<$^_> そのものは I<予約されます>。
8989
9090=begin original
9191
9292Perl identifiers that begin with digits or
9393punctuation characters are exempt from the effects of the C<package>
9494declaration and are always forced to be in package C<main>; they are
9595also exempt from C<strict 'vars'> errors. A few other names are also
9696exempt in these ways:
9797
9898=end original
9999
100100数字、句読点で始まる Perl の識別子は C<package> 宣言の
101101効果から逃れて、常に C<main> パッケージにあるものとして扱われます。
102102さらに以下のものも逃れます:
103103
104104 ENV STDIN
105105 INC STDOUT
106106 ARGV STDERR
107107 ARGVOUT
108108 SIG
109109
110110=begin original
111111
112112In particular, the special C<${^_XYZ}> variables are always taken
113113to be in package C<main>, regardless of any C<package> declarations
114114presently in scope.
115115
116116=end original
117117
118118特に、新しい特別な C<${^_XYZ}> 変数はスコープ内の C<package> 宣言に関わらず
119119常に C<main> パッケージとして扱われます。
120120
121121=head1 SPECIAL VARIABLES
122122
123123(特殊変数)
124124
125125=begin original
126126
127127The following names have special meaning to Perl. Most punctuation
128128names have reasonable mnemonics, or analogs in the shells.
129129Nevertheless, if you wish to use long variable names, you need only say:
130130
131131=end original
132132
133133以下の名前は Perl では特別な意味を持ちます。
134134記号的な名前の多くは記憶法があるか、シェルでの類推が可能です。
135135それでも長い名前を使用したい場合には
136136
137137 use English;
138138
139139=begin original
140140
141141at the top of your program. This aliases all the short names to the long
142142names in the current package. Some even have medium names, generally
143143borrowed from B<awk>. For more info, please see L<English>.
144144
145145=end original
146146
147147とプログラムの最初に書いてください。
148148これは、すべての短い名前の別名として、
149149カレントパッケージで長い名前を付けるものです。
150150B<awk> から持ってきた中間的な名前を持っているものもあります。
151151さらなる情報については、どうか L<English> を参照してください。
152152
153153=begin original
154154
155155Before you continue, note the sort order for variables. In general, we
156156first list the variables in case-insensitive, almost-lexigraphical
157157order (ignoring the C<{> or C<^> preceding words, as in C<${^UNICODE}>
158158or C<$^T>), although C<$_> and C<@_> move up to the top of the pile.
159159For variables with the same identifier, we list it in order of scalar,
160160array, hash, and bareword.
161161
162162=end original
163163
164164先に進む前に、変数のソート順に注意してください。
165165一般的に、変数を大文字小文字を無視して、ほとんど辞書順に並んでいます
166166(C<${^UNICODE}> や C<$^T> のように、先頭についている C<{> や C<^> は
167167無視します)が、C<$_> と C<@_> は先頭に来ます。
168168同じ識別子を持つ変数については、スカラ、配列、ハッシュ、裸の単語の順に
169169並べています。
170170
171171=head2 General Variables
172172
173173(一般変数)
174174
175175=over 8
176176
177177=item $ARG
178178
179179=item $_
180180X<$_> X<$ARG>
181181
182182=begin original
183183
184184The default input and pattern-searching space. The following pairs are
185185equivalent:
186186
187187=end original
188188
189189デフォルトの入力とパターン検索のスペース。
190190以下の 2つは同値です:
191191
192192=begin original
193193
194194 while (<>) {...} # equivalent only in while!
195195 while (defined($_ = <>)) {...}
196196
197197=end original
198198
199199 while (<>) {...} # while の中でのみ等価!
200200 while (defined($_ = <>)) {...}
201201
202202 /^Subject:/
203203 $_ =~ /^Subject:/
204204
205205 tr/a-z/A-Z/
206206 $_ =~ tr/a-z/A-Z/
207207
208208 chomp
209209 chomp($_)
210210
211211=begin original
212212
213213Here are the places where Perl will assume C<$_> even if you don't use it:
214214
215215=end original
216216
217217あなたが使いたくなくても Perl が C<$_> を仮定する場合がいくつかあります:
218218
219219=over 3
220220
221221=item *
222222
223223=begin original
224224
225225The following functions use C<$_> as a default argument:
226226
227227=end original
228228
229229以下の関数は C<$_> をデフォルト引数として使います:
230230
231231=begin original
232232
233233abs, alarm, chomp, chop, chr, chroot,
234234cos, defined, eval, evalbytes, exp, fc, glob, hex, int, lc,
235235lcfirst, length, log, lstat, mkdir, oct, ord, pos, print, printf,
236236quotemeta, readlink, readpipe, ref, require, reverse (in scalar context only),
237237rmdir, say, sin, split (for its second
238238argument), sqrt, stat, study, uc, ucfirst,
239239unlink, unpack.
240240
241241=end original
242242
243243abs, alarm, chomp, chop, chr, chroot,
244244cos, defined, eval, evalbytes, exp, fc, glob, hex, int, lc,
245245lcfirst, length, log, lstat, mkdir, oct, ord, pos, print, printf,
246246quotemeta, readlink, readpipe, ref, require, reverse (スカラコンテキストのみ),
247247rmdir, say, sin, split (の 2 番目の引数),
248248sqrt, stat, study, uc, ucfirst,
249249unlink, unpack
250250
251251=item *
252252
253253=begin original
254254
255255All file tests (C<-f>, C<-d>) except for C<-t>, which defaults to STDIN.
256256See L<perlfunc/-X>
257257
258258=end original
259259
260260デフォルトが STDIN である C<-t> を除く全てのファイルテスト(C<-f>, C<-d>)。
261261L<perlfunc/-X> を参照してください。
262262
263263=item *
264264
265265=begin original
266266
267267The pattern matching operations C<m//>, C<s///> and C<tr///> (aka C<y///>)
268268when used without an C<=~> operator.
269269
270270=end original
271271
272272C<=~> 演算子なしで用いられたパターンマッチ演算 C<m//>, C<s///>, C<tr///>
273273(またの名を C<y///>)。
274274
275275=item *
276276
277277=begin original
278278
279279The default iterator variable in a C<foreach> loop if no other
280280variable is supplied.
281281
282282=end original
283283
284284C<foreach> ループでの他の変数が補われなかった場合のデフォルトの繰り返し変数。
285285
286286=item *
287287
288288=begin original
289289
290290The implicit iterator variable in the C<grep()> and C<map()> functions.
291291
292292=end original
293293
294294C<grep()> 関数と C<map()> 関数の暗黙の繰り返し変数。
295295
296296=item *
297297
298298=begin original
299299
300300The implicit variable of C<given()>.
301301
302302=end original
303303
304304C<given()> の暗黙の変数。
305305
306306=item *
307307
308308=begin original
309309
310310The default place to put the next value or input record
311311when a C<< <FH> >>, C<readline>, C<readdir> or C<each>
312312operation's result is tested by itself as the sole criterion of a C<while>
313313test. Outside a C<while> test, this will not happen.
314314
315315=end original
316316
317317C<< <FH> >>, C<readline>, C<readdir>, C<each> が単独で C<while> テストで
318318テストされた場合の、次の値や入力レコードを入れるデフォルトの場所。
319319C<while> テスト以外ではこれは起こりません。
320320
321321=back
322322
323323=begin original
324324
325325C<$_> is a global variable.
326326
327327=end original
328328
329329C<$_> はグローバル変数です。
330330
331331=begin original
332332
333333However, between perl v5.10.0 and v5.24.0, it could be used lexically by
334334writing C<my $_>. Making C<$_> refer to the global C<$_> in the same scope
335335was then possible with C<our $_>. This experimental feature was removed and is
336336now a fatal error, but you may encounter it in older code.
337337
338338=end original
339339
340340しかし、perl v5.10.0 から v5.24.0 の間、
341341C<my $_> と書くことでこれをレキシカルに使うことが出来ました。
342342同じスコープで C<$_> がグローバルな C<$_> を参照するのは
343343C<our $_> で可能になっていました。
344344この実験的機能は削除されて今では致命的エラーですが、
345345古いコードで見かけるかも知れません。
346346
347347=begin original
348348
349349Mnemonic: underline is understood in certain operations.
350350
351351=end original
352352
353353記憶法: 下線はある操作を覚えるためのもの。
354354
355355=item @ARG
356356
357357=item @_
358358X<@_> X<@ARG>
359359
360360=begin original
361361
362362Within a subroutine the array C<@_> contains the parameters passed to
363363that subroutine. Inside a subroutine, C<@_> is the default array for
364364the array operators C<pop> and C<shift>.
365365
366366=end original
367367
368368サブルーチンに入るときには、配列 C<@_> はサブルーチンに渡された
369369パラメータです。
370370サブルーチンの内部では、C<@_> は配列演算子 C<push>, C<shift> の
371371デフォルト配列です。
372372
373373=begin original
374374
375375See L<perlsub>.
376376
377377=end original
378378
379379L<perlsub> を参照して下さい。
380380
381381=item $LIST_SEPARATOR
382382
383383=item $"
384384X<$"> X<$LIST_SEPARATOR>
385385
386386=begin original
387387
388388When an array or an array slice is interpolated into a double-quoted
389389string or a similar context such as C</.../>, its elements are
390390separated by this value. Default is a space. For example, this:
391391
392392=end original
393393
394394配列や配列スライスがダブルクォートされた文字列あるいは C</.../> のような
395395同様のコンテキスト展開されたとき、その要素はこの値で分割されます。
396396デフォルトは空白です。
397397例えば、以下のものは:
398398
399399 print "The array is: @array\n";
400400
401401=begin original
402402
403403is equivalent to this:
404404
405405=end original
406406
407407以下と等価です:
408408
409409 print "The array is: " . join($", @array) . "\n";
410410
411411=begin original
412412
413413Mnemonic: works in double-quoted context.
414414
415415=end original
416416
417417記憶法: ダブルクォートされた内容に対して動作します。
418418
419419=item $PROCESS_ID
420420
421421=item $PID
422422
423423=item $$
424424X<$$> X<$PID> X<$PROCESS_ID>
425425
426426=begin original
427427
428428The process number of the Perl running this script. Though you I<can> set
429429this variable, doing so is generally discouraged, although it can be
430430invaluable for some testing purposes. It will be reset automatically
431431across C<fork()> calls.
432432
433433=end original
434434
435435このスクリプトを実行している Perl のプロセス番号です。
436436この変数に値を設定することは I<可能> ですが、そうすることは一般的に
437437非推奨です; しかしこれは一部のテストの目的には計り知れない価値があります。
438438C<fork()> 呼び出しがあると自動的にリセットされます。
439439
440440=begin original
441441
442442Note for Linux and Debian GNU/kFreeBSD users: Before Perl v5.16.0 perl
443443would emulate POSIX semantics on Linux systems using LinuxThreads, a
444444partial implementation of POSIX Threads that has since been superseded
445445by the Native POSIX Thread Library (NPTL).
446446
447447=end original
448448
449449Linux および Debian GNU/kFreeBSD ユーザーに対する注意: Perl v5.16.0 より
450450前では perl は LinuxThreads を使って Linux システムで POSIX の意味論を
451451エミュレートしていました; これは POSIX Threads の部分的な実装で、
452452Native POSIX Thread Library (NPTL) で置き換えられました。
453453
454454=begin original
455455
456456LinuxThreads is now obsolete on Linux, and caching C<getpid()>
457457like this made embedding perl unnecessarily complex (since you'd have
458458to manually update the value of $$), so now C<$$> and C<getppid()>
459459will always return the same values as the underlying C library.
460460
461461=end original
462462
463463LinuxThreads は Linux では古いもので、このように C<getpid()> を
464464キャッシュすると組み込み perl が不必要に複雑になります ($$ の値を手動で
465465更新する必要があるからです); それで今では C<$$> と C<getppid()> は常に
466466基礎となる C ライブラリと同じ値を返します。
467467
468468=begin original
469469
470470Debian GNU/kFreeBSD systems also used LinuxThreads up until and
471471including the 6.0 release, but after that moved to FreeBSD thread
472472semantics, which are POSIX-like.
473473
474474=end original
475475
476476Debian GNU/kFreeBSD システムは 6.0 リリースまで LinuxThreads を
477477使っていましたが、その後は POSIX 風の FreeBSD スレッドの意味論に
478478移行しました。
479479
480480=begin original
481481
482482To see if your system is affected by this discrepancy check if
483483C<getconf GNU_LIBPTHREAD_VERSION | grep -q NPTL> returns a false
484484value. NTPL threads preserve the POSIX semantics.
485485
486486=end original
487487
488488あなたのシステムがこの非一貫性の影響を受けるかどうかを調べるには、
489489C<getconf GNU_LIBPTHREAD_VERSION | grep -q NPTL> が偽を返すかどうかを
490490チェックしてください。
491491NTPL スレッドは POSIX の意味論を保存します。
492492
493493=begin original
494494
495495Mnemonic: same as shells.
496496
497497=end original
498498
499499記憶法: シェルと同じ。
500500
501501=item $PROGRAM_NAME
502502
503503=item $0
504504X<$0> X<$PROGRAM_NAME>
505505
506506=begin original
507507
508508Contains the name of the program being executed.
509509
510510=end original
511511
512512実行されているプログラムの名前を示します。
513513
514514=begin original
515515
516516On some (but not all) operating systems assigning to C<$0> modifies
517517the argument area that the C<ps> program sees. On some platforms you
518518may have to use special C<ps> options or a different C<ps> to see the
519519changes. Modifying the C<$0> is more useful as a way of indicating the
520520current program state than it is for hiding the program you're
521521running.
522522
523523=end original
524524
525525一部の(しかし全てではありません)オペレーティングシステムでは
526526C<$0> に代入を行なうことで B<ps> プログラムが見る引数エリアを修正します。
527527プラットフォームによっては、この変更を見るために 特殊な C<ps> オプションや、
528528他の C<ps> を使う必要があるものもあります。
529529C<$0> の修正は、実行しているプログラムを隠すよりは、
530530実行中のプログラムの状態を表示するときに、使うとよいでしょう。
531531
532532=begin original
533533
534534Note that there are platform-specific limitations on the maximum
535535length of C<$0>. In the most extreme case it may be limited to the
536536space occupied by the original C<$0>.
537537
538538=end original
539539
540540C<$0> の最大長にはプラットフォーム固有の制限があることに注意してください。
541541最も極端な場合では、元の C<$0> で占められているサイズに制限されます。
542542
543543=begin original
544544
545545In some platforms there may be arbitrary amount of padding, for
546546example space characters, after the modified name as shown by C<ps>.
547547In some platforms this padding may extend all the way to the original
548548length of the argument area, no matter what you do (this is the case
549549for example with Linux 2.2).
550550
551551=end original
552552
553553プラットフォームによっては、任意の量のパッディングがある場合があります;
554554例えば、C<ps> で見られる修正された名前の後の空白文字です。
555555プラットフォームによっては、このパッディングは、あなたが何をしたかに
556556関わらず、元の引数のエリア全体に拡張されるものもあります
557557(例えば、これは Linux 2.2 の場合です)。
558558
559559=begin original
560560
561561Note for BSD users: setting C<$0> does not completely remove "perl"
562562from the ps(1) output. For example, setting C<$0> to C<"foobar"> may
563563result in C<"perl: foobar (perl)"> (whether both the C<"perl: "> prefix
564564and the " (perl)" suffix are shown depends on your exact BSD variant
565565and version). This is an operating system feature, Perl cannot help it.
566566
567567=end original
568568
569569BSD ユーザーへの注意: C<$0> に値をセットしても、ps(1) の出力から
570570完全に "perl" の文字列は取り除かれません。
571571例えば、C<$0> に C<"foobar"> と設定すると、C<"perl: foobar (perl)"> という
572572結果になります
573573(C<"perl: "> 接頭辞と" (perl)" 接尾辞が表示されるかどうかは 、正確な
574574BSD の種類とバージョンに依存します)。
575575これはオペレーティングシステムの機能で、Perl は何もできません。
576576
577577=begin original
578578
579579In multithreaded scripts Perl coordinates the threads so that any
580580thread may modify its copy of the C<$0> and the change becomes visible
581581to ps(1) (assuming the operating system plays along). Note that
582582the view of C<$0> the other threads have will not change since they
583583have their own copies of it.
584584
585585=end original
586586
587587マルチスレッドスクリプトでは、どのスレッドも自身の C<$0> のコピーを
588588変更できて、その変更が(OS が対応しているとして) ps(1) で見えるように、
589589Perl がスレッドを調整します。
590590他のスレッドが持っている C<$0> の見え方は(各自が自身のコピーを
591591持っているので)変わらないことに注意してください。
592592
593593=begin original
594594
595595If the program has been given to perl via the switches C<-e> or C<-E>,
596596C<$0> will contain the string C<"-e">.
597597
598598=end original
599599
600600プログラムが perl に C<-e> または C<-E> オプション経由で与えられた場合、
601601C<$0> には文字列 C<"-e"> を含みます。
602602
603603=begin original
604604
605605On Linux as of perl v5.14.0 the legacy process name will be set with
606606C<prctl(2)>, in addition to altering the POSIX name via C<argv[0]> as
607607perl has done since version 4.000. Now system utilities that read the
608608legacy process name such as ps, top and killall will recognize the
609609name you set when assigning to C<$0>. The string you supply will be
610610cut off at 16 bytes, this is a limitation imposed by Linux.
611611
612612=end original
613613
614614Linux では perl v5.14.0 以降、perl がバージョン 4.000 以降行っていた
615615C<argv[0]> 経由での POSIX 名の置き換えに加えて、
616616レガシープロセス名は C<prctl(2)> で設定されます。
617617今では ps, top, killall のようにレガシープロセス名を読むユーティリティは
618618C<$0> に代入することに設定される名前を認識します。
619619指定した文字列は 16 バイトに切り詰められます; これは Linux による
620620制限です。
621621
622622=begin original
623623
624624Mnemonic: same as B<sh> and B<ksh>.
625625
626626=end original
627627
628628記憶法: B<sh> や B<ksh> と同じ。
629629
630630=item $REAL_GROUP_ID
631631
632632=item $GID
633633
634634=item $(
635635X<$(> X<$GID> X<$REAL_GROUP_ID>
636636
637637=begin original
638638
639639The real gid of this process. If you are on a machine that supports
640640membership in multiple groups simultaneously, gives a space separated
641641list of groups you are in. The first number is the one returned by
642642C<getgid()>, and the subsequent ones by C<getgroups()>, one of which may be
643643the same as the first number.
644644
645645=end original
646646
647647本プロセスの実 gid を示します。
648648同時に複数のグループに所属できるマシンでは、所属するグループをスペースで
649649区切ったリストが得られます。
650650最初の数値は、C<getgid()> で返されるものです; その後に C<getgroups()> が
651651返す値が続き、その中の 1 つは、最初の値と同じかもしれません。
652652
653653=begin original
654654
655655However, a value assigned to C<$(> must be a single number used to
656656set the real gid. So the value given by C<$(> should I<not> be assigned
657657back to C<$(> without being forced numeric, such as by adding zero. Note
658658that this is different to the effective gid (C<$)>) which does take a
659659list.
660660
661661=end original
662662
663663しかし、C<$(> に代入された値は実際の gid に設定された値の
664664一つでなければなりません。
665665従って、 C<$(> で与えられた値はゼロを足すことによって
666666数値化することなく C<$(> に書き戻すべきではありません。
667667これはリストが得られる実行 GID (C<$)>) とは違うことに注意してください。
668668
669669=begin original
670670
671671You can change both the real gid and the effective gid at the same
672672time by using C<POSIX::setgid()>. Changes
673673to C<$(> require a check to C<$!>
674674to detect any possible errors after an attempted change.
675675
676676=end original
677677
678678C<POSIX::setgid()> を使って、実 GID と実効 GID の両方を同時に変更できます。
679679C<$(> を変更した場合は、変更しようとしたときに起こりうるエラーを検出するために
680680C<$!> をチェックする必要があります。
681681
682682=begin original
683683
684684Mnemonic: parentheses are used to I<group> things. The real gid is the
685685group you I<left>, if you're running setgid.
686686
687687=end original
688688
689689記憶法: 括弧は、I<グループ化>に使われます。
690690setgid で実行中であれば、実 gid は I<left> した、つまり離れたグループです。
691691
692692=item $EFFECTIVE_GROUP_ID
693693
694694=item $EGID
695695
696696=item $)
697697X<$)> X<$EGID> X<$EFFECTIVE_GROUP_ID>
698698
699699=begin original
700700
701701The effective gid of this process. If you are on a machine that
702702supports membership in multiple groups simultaneously, gives a space
703703separated list of groups you are in. The first number is the one
704704returned by C<getegid()>, and the subsequent ones by C<getgroups()>,
705705one of which may be the same as the first number.
706706
707707=end original
708708
709709本プロセスの実効 gid を示します。
710710同時に複数のグループに所属できるマシンでは、所属するグループをスペースで
711711区切ったリストが得られます。
712712最初の数値は、C<getegid()> で返されるものです; その後に C<getgroups()> が
713713返す値が続き、その中の 1 つは、最初の値と同じかもしれません。
714714
715715=begin original
716716
717717Similarly, a value assigned to C<$)> must also be a space-separated
718718list of numbers. The first number sets the effective gid, and
719719the rest (if any) are passed to C<setgroups()>. To get the effect of an
720720empty list for C<setgroups()>, just repeat the new effective gid; that is,
721721to force an effective gid of 5 and an effectively empty C<setgroups()>
722722list, say C< $) = "5 5" >.
723723
724724=end original
725725
726726同様に、C<$)> へ代入する値はスペースで区切られた数値の
727727リストでなければなりません。
728728最初の数値は実効 gid を設定し、残りの数値は(もしあれば) C<setgroups()> に
729729渡されます。
730730C<setgroups()> に空リストを渡したい場合は、単に新しい実効 gid を
731731繰り返してください; つまり、実効 gid を 5 にして、C<setgroups()> に空リストを
732732渡したい場合は、C< $) = "5 5" > としてください。
733733
734734=begin original
735735
736736You can change both the effective gid and the real gid at the same
737737time by using C<POSIX::setgid()> (use only a single numeric argument).
738738Changes to C<$)> require a check to C<$!> to detect any possible errors
739739after an attempted change.
740740
741741=end original
742742
743743C<POSIX::setgid()> を使って、実効 GID と実 GID を同時に変更できます
744744(1 つの数値引数だけが使えます)。
745745C<$)> を変更した場合は、変更時に起こりうるエラーを検出するために C<$!> の
746746チェックが必要です。
747747
748748=begin original
749749
750750C<< $< >>, C<< $> >>, C<$(> and C<$)> can be set only on
751751machines that support the corresponding I<set[re][ug]id()> routine. C<$(>
752752and C<$)> can be swapped only on machines supporting C<setregid()>.
753753
754754=end original
755755
756756C<< $< >>, C<< $> >>, C<$(>, C<$)> は、実行するマシンで、
757757対応する I<set[re][ug]id()> ルーティンがサポートされているときにのみ
758758設定可能です。
759759C<$(> と C<$)> の交換は、
760760C<setregid()> がサポートされているマシンでのみ可能です。
761761
762762=begin original
763763
764764Mnemonic: parentheses are used to I<group> things. The effective gid
765765is the group that's I<right> for you, if you're running setgid.
766766
767767=end original
768768
769769記憶法: 括弧は、I<グループ化>に使われます。
770770setgid で実行中であれば、実効 gid は right な、つまり正しいグループです。
771771
772772=item $REAL_USER_ID
773773
774774=item $UID
775775
776776=item $<
777777X<< $< >> X<$UID> X<$REAL_USER_ID>
778778
779779=begin original
780780
781781The real uid of this process. You can change both the real uid and the
782782effective uid at the same time by using C<POSIX::setuid()>. Since
783783changes to C<< $< >> require a system call, check C<$!> after a change
784784attempt to detect any possible errors.
785785
786786=end original
787787
788788本プロセスの実 uid を示します。
789789C<POSIX::setuid()> を使って、実効 UID と実 UID を同時に変更できます。
790790C<< $< >> の変更にはシステムコールが必要なので、起こりうるエラーを
791791検出するために C<$!> のチェックが必要です。
792792
793793=begin original
794794
795795Mnemonic: it's the uid you came I<from>, if you're running setuid.
796796
797797=end original
798798
799799記憶法: setuid で実行中であれば、そこ「から」来た uid です。
800800
801801=item $EFFECTIVE_USER_ID
802802
803803=item $EUID
804804
805805=item $>
806806X<< $> >> X<$EUID> X<$EFFECTIVE_USER_ID>
807807
808808=begin original
809809
810810The effective uid of this process. For example:
811811
812812=end original
813813
814814本プロセスの実効 uid を示します。
815815例えば:
816816
817817=begin original
818818
819819 $< = $>; # set real to effective uid
820820 ($<,$>) = ($>,$<); # swap real and effective uids
821821
822822=end original
823823
824824 $< = $>; # 実 uid に実効 uid を設定
825825 ($<,$>) = ($>,$<); # 実 uid と実効 uid を交換
826826
827827=begin original
828828
829829You can change both the effective uid and the real uid at the same
830830time by using C<POSIX::setuid()>. Changes to C<< $> >> require a check
831831to C<$!> to detect any possible errors after an attempted change.
832832
833833=end original
834834
835835C<POSIX::setuid()> を使って、実効 UID と実 UID を同時に変更できます。
836836C<< $> >> を変更した場合は、変更時に起こりうるエラーを検出するために
837837C<$!> のチェックが必要です。
838838
839839=begin original
840840
841841C<< $< >> and C<< $> >> can be swapped only on machines
842842supporting C<setreuid()>.
843843
844844=end original
845845
846846C<< $< >> と C<< $> >> の交換は、C<setreuid()> をサポートしている
847847マシンでのみ可能です。
848848
849849=begin original
850850
851851Mnemonic: it's the uid you went I<to>, if you're running setuid.
852852
853853=end original
854854
855855記憶法: setuid で実行中であれば、そこ I<へ> 行く uid です。
856856
857857=item $SUBSCRIPT_SEPARATOR
858858
859859=item $SUBSEP
860860
861861=item $;
862862X<$;> X<$SUBSEP> X<SUBSCRIPT_SEPARATOR>
863863
864864=begin original
865865
866866The subscript separator for multidimensional array emulation. If you
867867refer to a hash element as
868868
869869=end original
870870
871871多次元配列のエミュレートのための添え字の区切文字。
872872ハッシュの要素を
873873
874874 $foo{$x,$y,$z}
875875
876876=begin original
877877
878878it really means
879879
880880=end original
881881
882882のようにして参照すると、実際には以下のようになります
883883
884884 $foo{join($;, $x, $y, $z)}
885885
886886=begin original
887887
888888But don't put
889889
890890=end original
891891
892892しかし、以下のようにしてはいけません
893893
894894=begin original
895895
896896 @foo{$x,$y,$z} # a slice--note the @
897897
898898=end original
899899
900900 @foo{$x,$y,$z} # スライス--@ に注意
901901
902902=begin original
903903
904904which means
905905
906906=end original
907907
908908これは以下の意味になります
909909
910910 ($foo{$x},$foo{$y},$foo{$z})
911911
912912=begin original
913913
914914Default is "\034", the same as SUBSEP in B<awk>. If your keys contain
915915binary data there might not be any safe value for C<$;>.
916916
917917=end original
918918
919919デフォルトは "\034" で、C<awk> の SUBSEP と同じです。
920920使おうとしている key の値がバイナリのデータを含むならば、
921921C<$;> に設定する安全な値などはないことになります。
922922
923923=begin original
924924
925925Consider using "real" multidimensional arrays as described
926926in L<perllol>.
927927
928928=end original
929929
930930L<perllol> で記述している「本物の」多次元配列を使うようにしてください。
931931
932932=begin original
933933
934934Mnemonic: comma (the syntactic subscript separator) is a semi-semicolon.
935935
936936=end original
937937
938938記憶法: コンマ (構文上の添え字区切り文字) はセミ−セミコロンなのです。
939939
940940=item $a
941941
942942=item $b
943943X<$a> X<$b>
944944
945945=begin original
946946
947947Special package variables when using C<sort()>, see L<perlfunc/sort>.
948948Because of this specialness C<$a> and C<$b> don't need to be declared
949949(using C<use vars>, or C<our()>) even when using the C<strict 'vars'>
950950pragma. Don't lexicalize them with C<my $a> or C<my $b> if you want to
951951be able to use them in the C<sort()> comparison block or function.
952952
953953=end original
954954
955955C<sort()> を使うときの特殊パッケージ変数です; L<perlfunc/sort> を
956956参照してください。
957957この特殊性により、C<$a> と C<$b> は、たとえ C<strict 'vars'> プラグマを
958958使っているときでも (C<use vars> や C<our()> を使って) 宣言する必要が
959959ありません。
960960これを C<sort()> 比較ブロックや関数で使えるようにしたい場合は、
961961C<my $a> や C<my $b> としてレキシカル化しないでください。
962962
963963=item %ENV
964964X<%ENV>
965965
966966=begin original
967967
968968The hash C<%ENV> contains your current environment. Setting a
969969value in C<ENV> changes the environment for any child processes
970970you subsequently C<fork()> off.
971971
972972=end original
973973
974974ハッシュ C<%ENV> には、その時点の環境変数が設定されています。
975975C<ENV> に値を設定することで、
976976以後に C<fork()> した子プロセスの環境変数を変更します。
977977
978978=begin original
979979
980980As of v5.18.0, both keys and values stored in C<%ENV> are stringified.
981981
982982=end original
983983
984984v5.18.0 から、C<%ENV> に補完されたキーと値の両方は文字列化されます。
985985
986986 my $foo = 1;
987987 $ENV{'bar'} = \$foo;
988988 if( ref $ENV{'bar'} ) {
989989 say "Pre 5.18.0 Behaviour";
990990 } else {
991991 say "Post 5.18.0 Behaviour";
992992 }
993993
994994=begin original
995995
996996Previously, only child processes received stringified values:
997997
998998=end original
999999
10001000以前は、子プロセスのみが文字列化された値を受け取っていました:
10011001
10021002 my $foo = 1;
10031003 $ENV{'bar'} = \$foo;
10041004
10051005 # Always printed 'non ref'
10061006 system($^X, '-e',
10071007 q/print ( ref $ENV{'bar'} ? 'ref' : 'non ref' ) /);
10081008
10091009=begin original
10101010
10111011This happens because you can't really share arbitrary data structures with
10121012foreign processes.
10131013
10141014=end original
10151015
10161016これは、外部プロセスと本当に任意のデータ構造を共有することができないために
10171017起きます。
10181018
10191019=item $OLD_PERL_VERSION
10201020
10211021=item $]
10221022X<$]> X<$OLD_PERL_VERSION>
10231023
10241024=begin original
10251025
10261026The revision, version, and subversion of the Perl interpreter, represented
10271027as a decimal of the form 5.XXXYYY, where XXX is the version / 1e3 and YYY
10281028is the subversion / 1e6. For example, Perl v5.10.1 would be "5.010001".
10291029
10301030=end original
10311031
103210325.XXXYYY 型式の小数で表現される Perl インタプリタの
10331033revision, version, subversion
10341034(XXX は version / 1e3、 YYY は subversion / 1e6)。
10351035例えば、、Perl v5.10.1 は "5.010001" です。
10361036
10371037=begin original
10381038
10391039This variable can be used to determine whether the Perl interpreter
10401040executing a script is in the right range of versions:
10411041
10421042=end original
10431043
10441044スクリプトの最初で、そのスクリプトを実行しているインタプリタのバージョンが
10451045適切な範囲内にあるかを調べる、といったことができます:
10461046
10471047 warn "No PerlIO!\n" if $] lt '5.008';
10481048
10491049=begin original
10501050
10511051When comparing C<$]>, string comparison operators are B<highly
10521052recommended>. The inherent limitations of binary floating point
10531053representation can sometimes lead to incorrect comparisons for some
10541054numbers on some architectures.
10551055
10561056=end original
10571057
10581058C<$]> と比較する場合は、文字列比較演算子を B<強く勧めます> 。
10591059バイナリ浮動小数点表現が生来持つ制限により、アーキテクチャと数値によっては
10601060比較が正しくないことがあります。
10611061
10621062=begin original
10631063
10641064See also the documentation of C<use VERSION> and C<require VERSION>
10651065for a convenient way to fail if the running Perl interpreter is too old.
10661066
10671067=end original
10681068
10691069実行する Perl インタプリタが古すぎる場合に終了する便利な方法に
10701070ついては C<use VERSION> と C<require VERSION> のドキュメントも
10711071参照して下さい。
10721072
10731073=begin original
10741074
10751075See L</$^V> for a representation of the Perl version as a L<version>
10761076object, which allows more flexible string comparisons.
10771077
10781078=end original
10791079
10801080より柔軟な文字列比較が可能な L<version> オブジェクトとしての
10811081Perl バージョン表現については L</$^V> を参照してください。
10821082
10831083=begin original
10841084
10851085The main advantage of C<$]> over C<$^V> is that it works the same on any
10861086version of Perl. The disadvantages are that it can't easily be compared
10871087to versions in other formats (e.g. literal v-strings, "v1.2.3" or
10881088version objects) and numeric comparisons can occasionally fail; it's good
10891089for string literal version checks and bad for comparing to a variable
10901090that hasn't been sanity-checked.
10911091
10921092=end original
10931093
10941094C<$^V> に対する C<$]> の主な利点は、どのバージョンの Perl でも同様に
10951095動作することです。
10961096欠点は、他の型式のバージョン (例えばリテラルな v-文字列、"v1.2.3"、
10971097バージョンオブジェクト) と簡単に比較できず、数値比較はときどき
10981098失敗することです; 文字列リテラルバージョンチェックとしては良いですが、
10991099正気チェックをされていない変数と比較するには良くないです。
11001100
11011101=begin original
11021102
11031103The C<$OLD_PERL_VERSION> form was added in Perl v5.20.0 for historical
11041104reasons but its use is discouraged. (If your reason to use C<$]> is to
11051105run code on old perls then referring to it as C<$OLD_PERL_VERSION> would
11061106be self-defeating.)
11071107
11081108=end original
11091109
11101110C<$OLD_PERL_VERSION> 型式は歴史的理由により Perl v5.20.0 に追加されましたが、
11111111この使用は非推奨です。
11121112(C<$]> を使う理由が古い perl でコードを実行することなら、これを
11131113C<$OLD_PERL_VERSION> して参照すると自滅することになります。)
11141114
11151115=begin original
11161116
11171117Mnemonic: Is this version of perl in the right bracket?
11181118
11191119=end original
11201120
11211121記憶法: Perl のバージョンは、正しい範囲 (right bracket) にあるか。
11221122
11231123=item $SYSTEM_FD_MAX
11241124
11251125=item $^F
11261126X<$^F> X<$SYSTEM_FD_MAX>
11271127
11281128=begin original
11291129
11301130The maximum system file descriptor, ordinarily 2. System file
11311131descriptors are passed to C<exec()>ed processes, while higher file
11321132descriptors are not. Also, during an
11331133C<open()>, system file descriptors are
11341134preserved even if the C<open()> fails (ordinary file descriptors are
11351135closed before the C<open()> is attempted). The close-on-exec
11361136status of a file descriptor will be decided according to the value of
11371137C<$^F> when the corresponding file, pipe, or socket was opened, not the
11381138time of the C<exec()>.
11391139
11401140=end original
11411141
11421142システムが使用するファイル記述子の最大値を示し、通常は 2 です。
11431143システムファイル記述子は、C<exec()> されたプロセスに渡されますが、
11441144それ以降のファイル記述子は渡されません。
11451145また、C<open()> の実行中は、システムファイル記述子は、
11461146たとえ C<open()> が失敗しても、保存されます
11471147(通常のファイル記述子は、C<open()> が実行される前にクローズされます)。
11481148ファイル記述子の close-on-exec のステータスは、C<exec()> 時ではなく、
11491149対応するファイル、パイプソケットの open 時の C<$^F> の値によって
11501150決められます。
11511151
11521152=item @F
11531153X<@F>
11541154
11551155=begin original
11561156
11571157The array C<@F> contains the fields of each line read in when autosplit
11581158mode is turned on. See L<perlrun> for the B<-a> switch. This array
11591159is package-specific, and must be declared or given a full package name
11601160if not in package main when running under C<strict 'vars'>.
11611161
11621162=end original
11631163
11641164自動 split モードが有効の場合、配列 C<@F> には読み込んだ行のフィールドを
11651165含みます。
11661166B<-a> オプションについては L<perlrun> を参照してください。
11671167この配列はパッケージ固有であり、もし C<strict 'vars'> で実行していて
11681168パッケージ main 以外の場合は完全なパッケージ名で定義したり与えたり
11691169しなければなりません。
11701170
11711171=item @INC
11721172X<@INC>
11731173
11741174=begin original
11751175
11761176The array C<@INC> contains the list of places that the C<do EXPR>,
11771177C<require>, or C<use> constructs look for their library files. It
11781178initially consists of the arguments to any B<-I> command-line
11791179switches, followed by the default Perl library, probably
1180F</usr/local/lib/perl>.
1180F</usr/local/lib/perl>, followed by ".", to represent the current
1181Prior to Perl 5.26, C<.> -which represents the current directory, was included
1181directory. ("." will not be appended if taint checks are enabled,
1182in C<@INC>; it has been removed. This change in behavior is documented
1182either by C<-T> or by C<-t>, or if configured not to do so by the
1183in L<C<PERL_USE_UNSAFE_INC>|perlrun/PERL_USE_UNSAFE_INC> and it is
1183C<-Ddefault_inc_excludes_dot> compile time option.) If you need to
1184not recommended that C<.> be re-added to C<@INC>.
1184modify this at runtime, you should use the C<use lib> pragma to get
1185If you need to modify C<@INC> at runtime, you should use the C<use lib> pragma
1185the machine-dependent library properly loaded also:
1186to get the machine-dependent library properly loaded as well:
11871186
11881187=end original
11891188
11901189配列 C<@INC> には、C<do EXPR>, C<require>, C<use> によってライブラリファイルを
11911190探すときに評価する場所のリストが納められています。
11921191初期状態では、コマンドラインスイッチ B<-I> の引数とデフォルトの
1193Perl ライブラリディレクトリ (おそらく F</usr/local/lib/perl5>)
1192Perl ライブラリディレクトリ (おそらく F</usr/local/lib/perl5>)
1194順につなげたものです。
1193カレントディレクトリを表わす "." を順につなげたものです。
1195Perl 5.26 より前では、カレントディレクトリを表す C<.>
1194(C<-T> C<-t> によって汚染チェックが有効の場合か、
1196 C<@INC> に含まれていました; これは削除されました。
1195これをしないように C<-Ddefault_inc_excludes_dot> コンパイル時オプションを
1197この振る舞の変更
1196設定してない場合、"." は追加されません。)
1198L<C<PERL_USE_UNSAFE_INC>|perlrun/PERL_USE_UNSAFE_INC> 文書化さていて
1197実行時を変更する必要がある場合はマシン依存のライブラリも正しく
1199C<@INC> に C<.> を再追加するのは推奨されません。
1200実行時に C<@INC> 変更する必要がある場合は、マシン依存のライブラリも正しく
12011198読み込むために C<use lib> を使うべきです:
12021199
12031200 use lib '/mypath/libdir/';
12041201 use SomeMod;
12051202
12061203=begin original
12071204
12081205You can also insert hooks into the file inclusion system by putting Perl
12091206code directly into C<@INC>. Those hooks may be subroutine references,
12101207array references or blessed objects. See L<perlfunc/require> for details.
12111208
12121209=end original
12131210
12141211Perl のコードを直接 C<@INC> に入れることで、ファイルインクルード機構に
12151212フックを挿入できます。
12161213このフックはサブルーチンリファレンス、配列リファレンス、bless された
12171214オブジェクトが可能です。
12181215詳細については L<perlfunc/require> を参照してください。
12191216
12201217=item %INC
12211218X<%INC>
12221219
12231220=begin original
12241221
12251222The hash C<%INC> contains entries for each filename included via the
12261223C<do>, C<require>, or C<use> operators. The key is the filename
12271224you specified (with module names converted to pathnames), and the
12281225value is the location of the file found. The C<require>
12291226operator uses this hash to determine whether a particular file has
12301227already been included.
12311228
12321229=end original
12331230
12341231ハッシュ C<%INC> は、C<do>, C<require>, C<use> 演算子によって
12351232インクルードされた、個々のファイル名をエントリとして持っています。
12361233key は指定したファイル名(モジュール名はパス名に変換されます)で、
12371234value は見つかった場所となっています。
12381235C<require> 演算子は、指定されたファイル名が既に
12391236インクルードされているかを、このハッシュを使って調べます。
12401237
12411238=begin original
12421239
12431240If the file was loaded via a hook (e.g. a subroutine reference, see
12441241L<perlfunc/require> for a description of these hooks), this hook is
12451242by default inserted into C<%INC> in place of a filename. Note, however,
12461243that the hook may have set the C<%INC> entry by itself to provide some more
12471244specific info.
12481245
12491246=end original
12501247
12511248ファイルがフック(つまりサブルーチンリファレンス; フックに関する
12521249説明については L<perlfunc/require> を参照してください)経由で読み込まれた
12531250場合、このフックはデフォルトではファイル名の代わりに C<%INC> に挿入されます。
12541251しかし、フックはさらなる特定の情報を提供するために、自身で C<%INC> エントリを
12551252セットするかもしれないことに注意してください。
12561253
12571254=item $INPLACE_EDIT
12581255
12591256=item $^I
12601257X<$^I> X<$INPLACE_EDIT>
12611258
12621259=begin original
12631260
12641261The current value of the inplace-edit extension. Use C<undef> to disable
12651262inplace editing.
12661263
12671264=end original
12681265
12691266置き換え編集の拡張子の値を示します。
12701267置き換え編集を禁止するためには、C<undef> を設定します。
12711268
12721269=begin original
12731270
12741271Mnemonic: value of B<-i> switch.
12751272
12761273=end original
12771274
12781275記憶法: B<-i> スイッチの値。
12791276
12801277=item @ISA
12811278X<@ISA>
12821279
12831280=begin original
12841281
12851282Each package contains a special array called C<@ISA> which contains a list
12861283of that class's parent classes, if any. This array is simply a list of
12871284scalars, each of which is a string that corresponds to a package name. The
12881285array is examined when Perl does method resolution, which is covered in
12891286L<perlobj>.
12901287
12911288=end original
12921289
12931290それぞれのパッケージには C<@ISA> という名前の特殊配列があります;
12941291これは (もしあれば) そのクラスの親クラスのリストです。
12951292この変数は単なるスカラのリストで、それぞれはパッケージ名に対応する
12961293文字列です。
12971294この配列は Perl がメソッド解決を行うときにチェックされます; これは
12981295L<perlobj> に記述しています。
12991296
13001297=begin original
13011298
13021299To load packages while adding them to C<@ISA>, see the L<parent> pragma. The
13031300discouraged L<base> pragma does this as well, but should not be used except
13041301when compatibility with the discouraged L<fields> pragma is required.
13051302
13061303=end original
13071304
13081305To load packages while adding them to
13091306パッケージを読み込むために C<@ISA> に追加するには、L<parent> プラグマを
13101307参照してください。
13111308非推奨の L<base> プラグマは同じことをしますが、
13121309非推奨の L<fields> プラグマとの互換性が必要な場合を除いて、
13131310使うべきではありません。
13141311
13151312=item $^M
13161313X<$^M>
13171314
13181315=begin original
13191316
13201317By default, running out of memory is an untrappable, fatal error.
13211318However, if suitably built, Perl can use the contents of C<$^M>
13221319as an emergency memory pool after C<die()>ing. Suppose that your Perl
13231320were compiled with C<-DPERL_EMERGENCY_SBRK> and used Perl's malloc.
13241321Then
13251322
13261323=end original
13271324
13281325デフォルトでは、メモリ不足はトラップできない致命的エラーとなります。
13291326しかし、もし適切に構築されていれば、Perl は C<$^M> の中身を
13301327C<die()> した後の緊急用メモリとして使えます。
13311328Perl が C<-DPERL_EMERGENCY_SBRK> 付きでコンパイルされ、
13321329Perl の malloc を使うと仮定します。そして、
13331330
13341331 $^M = 'a' x (1 << 16);
13351332
13361333=begin original
13371334
13381335would allocate a 64K buffer for use in an emergency. See the
13391336F<INSTALL> file in the Perl distribution for information on how to
13401337add custom C compilation flags when compiling perl. To discourage casual
13411338use of this advanced feature, there is no L<English|English> long name for
13421339this variable.
13431340
13441341=end original
13451342
13461343とすると緊急用の 64K のバッファを割り当てます。
13471344perl をコンパイルするときに独自の C コンパイルフラグを追加する
13481345方法についての情報は、Perl 配布パッケージに含まれている
13491346F<INSTALL> ファイルを参照して下さい。
13501347この拡張機能を気軽に使えないようにするために、
13511348この変数には L<English|English> の長い名前はありません。
13521349
13531350=begin original
13541351
13551352This variable was added in Perl 5.004.
13561353
13571354=end original
13581355
13591356この変数は Perl 5.004 で追加されました。
13601357
13611358=item $OSNAME
13621359
13631360=item $^O
13641361X<$^O> X<$OSNAME>
13651362
13661363=begin original
13671364
13681365The name of the operating system under which this copy of Perl was
13691366built, as determined during the configuration process. For examples
13701367see L<perlport/PLATFORMS>.
13711368
13721369=end original
13731370
13741371この Perl が構築されたオペレーティングシステムの名前です;
13751372これは設定プロセス中に決定されます。
13761373例えば L<perlport/PLATFORMS> を参照してください。
13771374
13781375=begin original
13791376
13801377The value is identical to C<$Config{'osname'}>. See also L<Config>
13811378and the B<-V> command-line switch documented in L<perlrun>.
13821379
13831380=end original
13841381
13851382この値は C<$Config{'osname'}> と同じです。
13861383L<Config> と、L<perlrun> で文書化されている
13871384B<-V> コマンドラインスイッチも参照して下さい。
13881385
13891386=begin original
13901387
13911388In Windows platforms, C<$^O> is not very helpful: since it is always
13921389C<MSWin32>, it doesn't tell the difference between
1393139095/98/ME/NT/2000/XP/CE/.NET. Use C<Win32::GetOSName()> or
13941391Win32::GetOSVersion() (see L<Win32> and L<perlport>) to distinguish
13951392between the variants.
13961393
13971394=end original
13981395
13991396Windows プラットフォームでは、C<$^O> はあまり役に立ちません: これは常に
14001397C<MSWin32> となり、95/98/ME/NT/2000/XP/CE/.NET の違いを示していないからです。
14011398これらを区別するためには、C<Win32::GetOSName()> や Win32::GetOSVersion() を
14021399使ってください (L<Win32> と L<perlport> を参照してください)。
14031400
14041401=begin original
14051402
14061403This variable was added in Perl 5.003.
14071404
14081405=end original
14091406
14101407この変数は Perl 5.003 で追加されました。
14111408
14121409=item %SIG
14131410X<%SIG>
14141411
14151412=begin original
14161413
14171414The hash C<%SIG> contains signal handlers for signals. For example:
14181415
14191416=end original
14201417
14211418ハッシュ C<%SIG> にはシグナルのためのシグナルハンドラが含まれています。
14221419例えば:
14231420
14241421=begin original
14251422
14261423 sub handler { # 1st argument is signal name
14271424 my($sig) = @_;
14281425 print "Caught a SIG$sig--shutting down\n";
14291426 close(LOG);
14301427 exit(0);
14311428 }
14321429
14331430=end original
14341431
14351432 sub handler { # 最初の引数はシグナル名
14361433 my($sig) = @_;
14371434 print "Caught a SIG$sig--shutting down\n";
14381435 close(LOG);
14391436 exit(0);
14401437 }
14411438
14421439=begin original
14431440
14441441 $SIG{'INT'} = \&handler;
14451442 $SIG{'QUIT'} = \&handler;
14461443 ...
14471444 $SIG{'INT'} = 'DEFAULT'; # restore default action
14481445 $SIG{'QUIT'} = 'IGNORE'; # ignore SIGQUIT
14491446
14501447=end original
14511448
14521449 $SIG{'INT'} = \&handler;
14531450 $SIG{'QUIT'} = \&handler;
14541451 ...
14551452 $SIG{'INT'} = 'DEFAULT'; # デフォルトの動作を復元
14561453 $SIG{'QUIT'} = 'IGNORE'; # SIGQUIT を無視
14571454
14581455=begin original
14591456
14601457Using a value of C<'IGNORE'> usually has the effect of ignoring the
14611458signal, except for the C<CHLD> signal. See L<perlipc> for more about
14621459this special case.
14631460
14641461=end original
14651462
14661463C<'IGNORE'> という値は通常はシグナルの効果を無視するために使いますが、
14671464C<CHLD> シグナルは例外です。
14681465この特別な場合に関する詳細は L<perlipc> を参照して下さい。
14691466
14701467=begin original
14711468
14721469Here are some other examples:
14731470
14741471=end original
14751472
14761473以下にその他の例を示します:
14771474
14781475=begin original
14791476
14801477 $SIG{"PIPE"} = "Plumber"; # assumes main::Plumber (not
14811478 # recommended)
14821479 $SIG{"PIPE"} = \&Plumber; # just fine; assume current
14831480 # Plumber
14841481 $SIG{"PIPE"} = *Plumber; # somewhat esoteric
14851482 $SIG{"PIPE"} = Plumber(); # oops, what did Plumber()
14861483 # return??
14871484
14881485=end original
14891486
14901487 $SIG{"PIPE"} = "Plumber"; # main::Plumber を仮定します(非推奨)
14911488 $SIG{"PIPE"} = \&Plumber; # 問題なし; カレントの Plumber を仮定します
14921489 $SIG{"PIPE"} = *Plumber; # 少々難解
14931490 $SIG{"PIPE"} = Plumber(); # げげ、Plumber() は何を返すの??
14941491
14951492=begin original
14961493
14971494Be sure not to use a bareword as the name of a signal handler,
14981495lest you inadvertently call it.
14991496
15001497=end original
15011498
15021499裸の単語をシグナルハンドラの名前として使わないようにしてください;
15031500不注意で呼び出すのを避けるためです。
15041501
15051502=begin original
15061503
15071504If your system has the C<sigaction()> function then signal handlers
15081505are installed using it. This means you get reliable signal handling.
15091506
15101507=end original
15111508
15121509システムに sigaction() 関数がある場合は、シグナルハンドラはそれを使って
15131510インストールされます。
15141511これにより、信頼性のあるシグナルハンドリングが可能になります。
15151512
15161513=begin original
15171514
15181515The default delivery policy of signals changed in Perl v5.8.0 from
15191516immediate (also known as "unsafe") to deferred, also known as "safe
15201517signals". See L<perlipc> for more information.
15211518
15221519=end original
15231520
15241521デフォルトのシグナル配送ポリシーは Perl v5.8.0 に即時("unsafe"としても
15251522知られます)から保留(「安全なシグナル」としても知られます)に変更されました。
15261523さらなる情報については L<perlipc> を参照してください。
15271524
15281525=begin original
15291526
15301527Certain internal hooks can be also set using the C<%SIG> hash. The
15311528routine indicated by C<$SIG{__WARN__}> is called when a warning
15321529message is about to be printed. The warning message is passed as the
15331530first argument. The presence of a C<__WARN__> hook causes the
15341531ordinary printing of warnings to C<STDERR> to be suppressed. You can
15351532use this to save warnings in a variable, or turn warnings into fatal
15361533errors, like this:
15371534
15381535=end original
15391536
15401537ある種の内部フックも %SIG ハッシュを使ってセットされます。
15411538警告メッセージを表示しようとするときに C<$SIG{__WARN__}> で
15421539示されたルーチンが呼び出されます。
15431540警告メッセージは最初の引数として渡されます。
15441541C<__WARN__> フックがあると、通常の C<STDERR> への警告の出力は行われません。
15451542これを使って、警告メッセージを変数にいれたり、
15461543あるいは以下のようにして警告を致命的エラーに変えたり出来ます:
15471544
15481545 local $SIG{__WARN__} = sub { die $_[0] };
15491546 eval $proggie;
15501547
15511548=begin original
15521549
15531550As the C<'IGNORE'> hook is not supported by C<__WARN__>, you can
15541551disable warnings using the empty subroutine:
15551552
15561553=end original
15571554
15581555C<__WARN__> では C<'IGNORE'> フックには対応していないので、空サブルーチンを
15591556使って警告を無効に出来ます:
15601557
15611558 local $SIG{__WARN__} = sub {};
15621559
15631560=begin original
15641561
15651562The routine indicated by C<$SIG{__DIE__}> is called when a fatal
15661563exception is about to be thrown. The error message is passed as the
15671564first argument. When a C<__DIE__> hook routine returns, the exception
15681565processing continues as it would have in the absence of the hook,
15691566unless the hook routine itself exits via a C<goto &sub>, a loop exit,
15701567or a C<die()>. The C<__DIE__> handler is explicitly disabled during
15711568the call, so that you can die from a C<__DIE__> handler. Similarly
15721569for C<__WARN__>.
15731570
15741571=end original
15751572
15761573C<$SIG{__DIE__}> で示されるルーチンは
15771574致命的な例外がまさに投げられようとするときに呼び出されます。
15781575エラーメッセージは最初の引数として渡されます。
15791576C<__DIE__> フックから戻ると、例外処理はフックがなかったかのように
15801577再開されますが、フックルーチン自体が C<goto &sub>、ループ終了、
15811578C<die()> によって終了した場合を除きます。
15821579C<__DIE__> ハンドラは呼び出し中は明示的に無効になりますので、
15831580C<__DIE__> ハンドラから die できます。
15841581C<__WARN__> も同様です。
15851582
15861583=begin original
15871584
15881585The C<$SIG{__DIE__}> hook is called even inside an C<eval()>. It was
15891586never intended to happen this way, but an implementation glitch made
15901587this possible. This used to be deprecated, as it allowed strange action
15911588at a distance like rewriting a pending exception in C<$@>. Plans to
15921589rectify this have been scrapped, as users found that rewriting a
15931590pending exception is actually a useful feature, and not a bug.
15941591
15951592=end original
15961593
15971594C<$SIG{__DIE__}> は eval() の中でも呼び出されます。
15981595これは決してこのようになることを意図したものではありませんでしたが、
15991596実装上のミスでこれが可能になっていました。
16001597これは以前廃止予定でした; C<$@> で保留されている例外を書き換えるといった
16011598変わった行動を離れた場所でできるようにしていたからです。
16021599これを修正する計画は破棄されました;
16031600保留されている例外を書き換えるというのは実際有用な機能であることがわかり、
16041601またバグではないからです。
16051602
16061603=begin original
16071604
16081605C<__DIE__>/C<__WARN__> handlers are very special in one respect: they
16091606may be called to report (probable) errors found by the parser. In such
16101607a case the parser may be in inconsistent state, so any attempt to
16111608evaluate Perl code from such a handler will probably result in a
16121609segfault. This means that warnings or errors that result from parsing
16131610Perl should be used with extreme caution, like this:
16141611
16151612=end original
16161613
16171614C<__DIE__> と C<__WARN__> のハンドラは一つの点で非常に特別です:
16181615パーサによってエラー(であろうもの)を報告するために呼び出されることがある
16191616ことです。
16201617このような場合、パーサは不安定な状態になっているかもしれないので、
16211618ハンドラから Perl コードを評価しようとするとセグメンテーションフォールトが
16221619発生するかもしれません。
16231620Perl のパース中の警告やエラーは、以下のように非常に注意して扱うべきです;
16241621
16251622 require Carp if defined $^S;
16261623 Carp::confess("Something wrong") if defined &Carp::confess;
16271624 die "Something wrong, but could not load Carp to give "
16281625 . "backtrace...\n\t"
16291626 . "To see backtrace try starting Perl with -MCarp switch";
16301627
16311628=begin original
16321629
16331630Here the first line will load C<Carp> I<unless> it is the parser who
16341631called the handler. The second line will print backtrace and die if
16351632C<Carp> was available. The third line will be executed only if C<Carp> was
16361633not available.
16371634
16381635=end original
16391636
16401637一行目は、パーサが C<ハンドラ> を I<呼び出したのでなければ> C<Carp> を
16411638読み込みます。
16421639C<二行目> は、C<Carp> が使えるならバックとレースを表示して die します。
16431640三行目は C<Carp> が使えないときにのみ実行されます。
16441641
16451642=begin original
16461643
16471644Having to even think about the C<$^S> variable in your exception
16481645handlers is simply wrong. C<$SIG{__DIE__}> as currently implemented
16491646invites grievous and difficult to track down errors. Avoid it
16501647and use an C<END{}> or CORE::GLOBAL::die override instead.
16511648
16521649=end original
16531650
16541651例外ハンドラの中で C<$^S> を使おうなどとは考えてもいけません。
16551652現在の実装の C<$SIG{__DIE__}> は面倒を引き寄せ、エラーの追跡を困難にします。
16561653これの代わりに C<END{}> を使うか、CORE::GLOBAL::die を
16571654オーバーライドしてください。
16581655
16591656=begin original
16601657
16611658See L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>, and
16621659L<warnings> for additional information.
16631660
16641661=end original
16651662
16661663追加の情報については L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>,
16671664L<warnings> を参照して下さい。
16681665
16691666=item $BASETIME
16701667
16711668=item $^T
16721669X<$^T> X<$BASETIME>
16731670
16741671=begin original
16751672
16761673The time at which the program began running, in seconds since the
16771674epoch (beginning of 1970). The values returned by the B<-M>, B<-A>,
16781675and B<-C> filetests are based on this value.
16791676
16801677=end original
16811678
16821679プログラムを実行開始した時刻を、紀元 (1970年の始め) からの秒数で
16831680示したものです。
16841681ファイルテスト B<-M>、B<-A>、B<-C> で返される値は、この値に基づいています。
16851682
16861683=item $PERL_VERSION
16871684
16881685=item $^V
16891686X<$^V> X<$PERL_VERSION>
16901687
16911688=begin original
16921689
16931690The revision, version, and subversion of the Perl interpreter,
16941691represented as a L<version> object.
16951692
16961693=end original
16971694
16981695L<version> オブジェクトとして表現される Perl インタプリタの
16991696revision, version, subversion。
17001697
17011698=begin original
17021699
17031700This variable first appeared in perl v5.6.0; earlier versions of perl
17041701will see an undefined value. Before perl v5.10.0 C<$^V> was represented
17051702as a v-string rather than a L<version> object.
17061703
17071704=end original
17081705
17091706この変数は perl v5.6.0 で最初に現れました; それより前のバージョンでは
17101707未定義値となります。
17111708perl v5.10.0 以前では C<$^V> は L<version> オブジェクトではなく
17121709v-string 形式で表現されます。
17131710
17141711=begin original
17151712
17161713C<$^V> can be used to determine whether the Perl interpreter executing
17171714a script is in the right range of versions. For example:
17181715
17191716=end original
17201717
17211718C<$^V> はスクリプトを実行している Perl インタプリタのバージョンが
17221719正しい範囲に入っているかを調べるのに使えます。
17231720例えば:
17241721
17251722 warn "Hashes not randomized!\n" if !$^V or $^V lt v5.8.1
17261723
17271724=begin original
17281725
17291726While version objects overload stringification, to portably convert
17301727C<$^V> into its string representation, use C<sprintf()>'s C<"%vd">
17311728conversion, which works for both v-strings or version objects:
17321729
17331730=end original
17341731
17351732移植性がある形で C<$^V> を文字列表現に変換するために、
17361733バージョンオブジェクトは文字列化をオーバーロードしますが、
17371734v-文字列とバージョンオブジェクトの療養で動作する
17381735C<sprintf()> の C<"%vd"> 変換を使ってください。
17391736
17401737=begin original
17411738
17421739 printf "version is v%vd\n", $^V; # Perl's version
17431740
17441741=end original
17451742
17461743 printf "version is v%vd\n", $^V; # Perl のバージョン
17471744
17481745=begin original
17491746
17501747See the documentation of C<use VERSION> and C<require VERSION>
17511748for a convenient way to fail if the running Perl interpreter is too old.
17521749
17531750=end original
17541751
17551752実行する Perl インタプリタが古すぎる場合に終了する便利な方法については
17561753C<use VERSION> と C<require VERSION> のドキュメントを参照して下さい。
17571754
17581755=begin original
17591756
17601757See also C<L</$]>> for a decimal representation of the Perl version.
17611758
17621759=end original
17631760
17641761Perl バージョンの 10 進表現については C<L</$]>> も参照して下さい。
17651762
17661763=begin original
17671764
17681765The main advantage of C<$^V> over C<$]> is that, for Perl v5.10.0 or
17691766later, it overloads operators, allowing easy comparison against other
17701767version representations (e.g. decimal, literal v-string, "v1.2.3", or
17711768objects). The disadvantage is that prior to v5.10.0, it was only a
17721769literal v-string, which can't be easily printed or compared, whereas
17731770the behavior of C<$]> is unchanged on all versions of Perl.
17741771
17751772=end original
17761773
17771774Perl 5.10.0 以降での、C<$]> に対する C<$^V> の主な利点は、これは演算子を
17781775オーバーロードするので、他のバージョン表現 (例えば 10 進数、
17791776リテラルな v-文字列、"v1.2.3"、オブジェクト)との比較が簡単であることです。
17801777v5.10.0 より前での欠点は、これは単なるリテラルな v-文字列であるため、
17811778簡単に表示したり比較したり出来ないことです; 一方、
17821779C<$]> の振る舞いは全てのバージョンの Perl で変化しません。
17831780
17841781=begin original
17851782
17861783Mnemonic: use ^V for a version object.
17871784
17881785=end original
17891786
17901787記憶法: ^V をバージョンオブジェクトに使います。
17911788
17921789=item ${^WIN32_SLOPPY_STAT}
17931790X<${^WIN32_SLOPPY_STAT}> X<sitecustomize> X<sitecustomize.pl>
17941791
17951792=begin original
17961793
17971794If this variable is set to a true value, then C<stat()> on Windows will
17981795not try to open the file. This means that the link count cannot be
17991796determined and file attributes may be out of date if additional
18001797hardlinks to the file exist. On the other hand, not opening the file
18011798is considerably faster, especially for files on network drives.
18021799
18031800=end original
18041801
18051802この変数が真の値にセットされると、Windows での C<stat()> はファイルを
18061803オープンしようとはしません。
18071804これは、このファイルへの追加のハードリンクが存在する場合、リンクカウントを
18081805決定できませんし、ファイル属性が古いものになるかもしれないことを意味します。
18091806一方、ファイルを開かないので、(特にファイルがネットワークドライブにある
18101807場合は)大幅に高速です。
18111808
18121809=begin original
18131810
18141811This variable could be set in the F<sitecustomize.pl> file to
18151812configure the local Perl installation to use "sloppy" C<stat()> by
18161813default. See the documentation for B<-f> in
18171814L<perlrun|perlrun/"Command Switches"> for more information about site
18181815customization.
18191816
18201817=end original
18211818
18221819デフォルトで「ずさんな」C<stat()> を使うために、この変数は、ローカルな
18231820Perl を設定するための F<sitecustomize.pl> で設定できます。
18241821サイトカスタマイズに関するさらなる情報については
18251822L<perlrun|perlrun/"Command Switches"> の B<-f> を参照してください。
18261823
18271824=begin original
18281825
18291826This variable was added in Perl v5.10.0.
18301827
18311828=end original
18321829
18331830この変数は Perl v5.10.0 で追加されました。
18341831
18351832=item $EXECUTABLE_NAME
18361833
18371834=item $^X
18381835X<$^X> X<$EXECUTABLE_NAME>
18391836
18401837=begin original
18411838
18421839The name used to execute the current copy of Perl, from C's
18431840C<argv[0]> or (where supported) F</proc/self/exe>.
18441841
18451842=end original
18461843
18471844Perl バイナリ自身が実行された時の名前を C の argv[0] または (対応していれば)
18481845F</proc/self/exe> から持ってきたものです。
18491846
18501847=begin original
18511848
18521849Depending on the host operating system, the value of C<$^X> may be
18531850a relative or absolute pathname of the perl program file, or may
18541851be the string used to invoke perl but not the pathname of the
18551852perl program file. Also, most operating systems permit invoking
18561853programs that are not in the PATH environment variable, so there
18571854is no guarantee that the value of C<$^X> is in PATH. For VMS, the
18581855value may or may not include a version number.
18591856
18601857=end original
18611858
18621859ホスト OS に依存して、C<$^X> の値は perl プログラムファイルの絶対パスかも
18631860しれませんし、相対パスかもしれませんし、perl を起動するために使われる
18641861文字列ではありますが perl プログラムファイルのパス名ではないかもしれません。
18651862また、ほとんどの OS は PATH 環境変数にない位置のプログラムを起動することを
18661863許しているので、C<$^X> の値が PATH にある保証はありません。
18671864VMS では、この値はバージョン番号を含む場合も含まない場合もあります。
18681865
18691866=begin original
18701867
18711868You usually can use the value of C<$^X> to re-invoke an independent
18721869copy of the same perl that is currently running, e.g.,
18731870
18741871=end original
18751872
18761873通常は、現在実行中のものと同じ perl の独立したコピーを再起動するために
18771874C<$^X> の値を使えます; つまり:
18781875
18791876 @first_run = `$^X -le "print int rand 100 for 1..100"`;
18801877
18811878=begin original
18821879
18831880But recall that not all operating systems support forking or
18841881capturing of the output of commands, so this complex statement
18851882may not be portable.
18861883
18871884=end original
18881885
18891886しかし、全ての OS が fork やコマンドの出力の捕捉に対応しているわけでは
18901887ないので、この複雑な文は移植性がないかもしれないことを忘れないでください。
18911888
18921889=begin original
18931890
18941891It is not safe to use the value of C<$^X> as a path name of a file,
18951892as some operating systems that have a mandatory suffix on
18961893executable files do not require use of the suffix when invoking
18971894a command. To convert the value of C<$^X> to a path name, use the
18981895following statements:
18991896
19001897=end original
19011898
19021899C<$^X> の値をファイルのパス名として使うのは安全ではありません; 実行ファイルに
19031900固定の接尾辞があり、コマンドの起動時には接尾辞が不要な OS もあるからです。
19041901C<$^X> の値をパス名に変換するには、以下のコードを使ってください:
19051902
19061903=begin original
19071904
19081905 # Build up a set of file names (not command names).
19091906 use Config;
19101907 my $this_perl = $^X;
19111908 if ($^O ne 'VMS') {
19121909 $this_perl .= $Config{_exe}
19131910 unless $this_perl =~ m/$Config{_exe}$/i;
19141911 }
19151912
19161913=end original
19171914
19181915 # (コマンド名ではなく)ファイル名を構築する。
19191916 use Config;
19201917 my $this_perl = $^X;
19211918 if ($^O ne 'VMS') {
19221919 $this_perl .= $Config{_exe}
19231920 unless $this_perl =~ m/$Config{_exe}$/i;
19241921 }
19251922
19261923=begin original
19271924
19281925Because many operating systems permit anyone with read access to
19291926the Perl program file to make a copy of it, patch the copy, and
19301927then execute the copy, the security-conscious Perl programmer
19311928should take care to invoke the installed copy of perl, not the
19321929copy referenced by C<$^X>. The following statements accomplish
19331930this goal, and produce a pathname that can be invoked as a
19341931command or referenced as a file.
19351932
19361933=end original
19371934
19381935多くの OS が Perl のプログラムファイルのコピーを作って、コピーにパッチを当て、
19391936それを実行するための読み込み権限を全員に与えているので、セキュリティ
19401937意識のある Perl プログラマは C<$^X> で参照されているコピーではなく、
19411938インストールされている perl を起動するように気をつけるべきです。
19421939以下のコードはこの目的を達成し、コマンドとして起動したりファイルとして
19431940参照するためのパス名を作成します。
19441941
19451942 use Config;
19461943 my $secure_perl_path = $Config{perlpath};
19471944 if ($^O ne 'VMS') {
19481945 $secure_perl_path .= $Config{_exe}
19491946 unless $secure_perl_path =~ m/$Config{_exe}$/i;
19501947 }
19511948
19521949=back
19531950
19541951=head2 Variables related to regular expressions
19551952
19561953(正規表現に関する変数)
19571954
19581955=begin original
19591956
19601957Most of the special variables related to regular expressions are side
19611958effects. Perl sets these variables when it has a successful match, so
19621959you should check the match result before using them. For instance:
19631960
19641961=end original
19651962
19661963正規表現に関連する特殊変数のほとんどは副作用です。
19671964Perl はマッチングに成功したときにこれらの変数を設定するので、変数を
19681965使う前にマッチングの結果をチェックするべきです。
19691966例えば:
19701967
19711968 if( /P(A)TT(ER)N/ ) {
19721969 print "I found $1 and $2\n";
19731970 }
19741971
19751972=begin original
19761973
19771974These variables are read-only and dynamically-scoped, unless we note
19781975otherwise.
19791976
19801977=end original
19811978
19821979これらの変数は特に記さない限り読み込み専用で動的スコープを持ちます。
19831980
19841981=begin original
19851982
19861983The dynamic nature of the regular expression variables means that
19871984their value is limited to the block that they are in, as demonstrated
19881985by this bit of code:
19891986
19901987=end original
19911988
19921989正規表現変数の動的な特性により、以下のコード片で示されているように、
19931990変数の値はブロック内に制限されます:
19941991
19951992 my $outer = 'Wallace and Grommit';
19961993 my $inner = 'Mutt and Jeff';
19971994
19981995 my $pattern = qr/(\S+) and (\S+)/;
19991996
20001997 sub show_n { print "\$1 is $1; \$2 is $2\n" }
20011998
20021999 {
20032000 OUTER:
20042001 show_n() if $outer =~ m/$pattern/;
20052002
20062003 INNER: {
20072004 show_n() if $inner =~ m/$pattern/;
20082005 }
20092006
20102007 show_n();
20112008 }
20122009
20132010=begin original
20142011
20152012The output shows that while in the C<OUTER> block, the values of C<$1>
20162013and C<$2> are from the match against C<$outer>. Inside the C<INNER>
20172014block, the values of C<$1> and C<$2> are from the match against
20182015C<$inner>, but only until the end of the block (i.e. the dynamic
20192016scope). After the C<INNER> block completes, the values of C<$1> and
20202017C<$2> return to the values for the match against C<$outer> even though
20212018we have not made another match:
20222019
20232020=end original
20242021
20252022出力から分かることは、C<OUTER> ブロックの間では C<$1> と C<$2> の値は
20262023C<$outer> に対するマッチングからのものになります。
20272024C<INNER> ブロックの内側では、C<$1> と C<$2> の値は C<$inner> での
20282025マッチングからのものになりますが、ブロックの最後までです (つまり、
20292026動的スコープを持ちます)。
20302027C<INNER> ブロックの終了後、C<$1> と C<$2> の値は、他のマッチングがなくても
20312028C<$outer> に対するマッチングからのものになります:
20322029
20332030 $1 is Wallace; $2 is Grommit
20342031 $1 is Mutt; $2 is Jeff
20352032 $1 is Wallace; $2 is Grommit
20362033
20372034=head3 Performance issues
20382035
20392036(性能問題)
20402037
20412038=begin original
20422039
20432040Traditionally in Perl, any use of any of the three variables C<$`>, C<$&>
20442041or C<$'> (or their C<use English> equivalents) anywhere in the code, caused
20452042all subsequent successful pattern matches to make a copy of the matched
20462043string, in case the code might subsequently access one of those variables.
20472044This imposed a considerable performance penalty across the whole program,
20482045so generally the use of these variables has been discouraged.
20492046
20502047=end original
20512048
20522049Perl では伝統的に、C<$`>, C<$&>, C<$'> (または C<use English> での
20532050等価物) をコードのどこかで使うと、コードが引き続いてこれらの変数に
20542051アクセスするかもしれないので、引き続くすべての成功したパターンマッチングで
20552052マッチングした文字列のコピーを作ります。
20562053これはプログラム全体に対してかなりの性能上の負荷を掛けるので、、一般的に
20572054これらの変数の使用は非推奨です。
20582055
20592056=begin original
20602057
20612058In Perl 5.6.0 the C<@-> and C<@+> dynamic arrays were introduced that
20622059supply the indices of successful matches. So you could for example do
20632060this:
20642061
20652062=end original
20662063
20672064Perl 5.6.0 では、マッチングに成功したインデックスを提供する C<@-> と
20682065C<@+> 動的配列が導入されました。
20692066それで、たとえばこのようにできます:
20702067
20712068 $str =~ /pattern/;
20722069
20732070 print $`, $&, $'; # bad: performance hit
20742071
20752072 print # good: no performance hit
20762073 substr($str, 0, $-[0]),
20772074 substr($str, $-[0], $+[0]-$-[0]),
20782075 substr($str, $+[0]);
20792076
20802077=begin original
20812078
20822079In Perl 5.10.0 the C</p> match operator flag and the C<${^PREMATCH}>,
20832080C<${^MATCH}>, and C<${^POSTMATCH}> variables were introduced, that allowed
20842081you to suffer the penalties only on patterns marked with C</p>.
20852082
20862083=end original
20872084
20882085Perl 5.10.0 で C</p> マッチング演算子フラグと C<${^PREMATCH}>,
20892086C<${^MATCH}>, C<${^POSTMATCH}> 変数が導入され、C</p> でマークされた
20902087パターンのみが負荷を被るようにできるようになりました。
20912088
20922089=begin original
20932090
20942091In Perl 5.18.0 onwards, perl started noting the presence of each of the
20952092three variables separately, and only copied that part of the string
20962093required; so in
20972094
20982095=end original
20992096
21002097Perl 5.18.0 以降では、perl は三つの変数の存在を別々に注意するようになり、
21012098必要な部分文字列のみをコピーするようになりました; 従って、次の場合は
21022099
21032100 $`; $&; "abcdefgh" =~ /d/
21042101
21052102=begin original
21062103
21072104perl would only copy the "abcd" part of the string. That could make a big
21082105difference in something like
21092106
21102107=end original
21112108
21122109perl は文字列のうち "abcd" の部分のみをコピーします。
21132110これは次のようなものとは大きな違いになります
21142111
21152112 $str = 'x' x 1_000_000;
21162113 $&; # whoops
21172114 $str =~ /x/g # one char copied a million times, not a million chars
21182115
21192116=begin original
21202117
21212118In Perl 5.20.0 a new copy-on-write system was enabled by default, which
21222119finally fixes all performance issues with these three variables, and makes
21232120them safe to use anywhere.
21242121
21252122=end original
21262123
21272124Perl 5.20.0 では新しいコピーオンライトシステムがデフォルトで有効になり、
21282125これらの変数に関する性能問題はすべて最終的に修正され、これらをどこで使っても
21292126安全になりました。
21302127
21312128=begin original
21322129
21332130The C<Devel::NYTProf> and C<Devel::FindAmpersand> modules can help you
21342131find uses of these problematic match variables in your code.
21352132
21362133=end original
21372134
21382135C<Devel::NYTProf> と C<Devel::FindAmpersand> のモジュールは、コード中に
21392136これらの問題のあるマッチング変数の使用を探す助けになります。
21402137
21412138=over 8
21422139
21432140=item $<I<digits>> ($1, $2, ...)
21442141X<$1> X<$2> X<$3> X<$I<digits>>
21452142
21462143=begin original
21472144
21482145Contains the subpattern from the corresponding set of capturing
21492146parentheses from the last successful pattern match, not counting patterns
21502147matched in nested blocks that have been exited already.
21512148
21522149=end original
21532150
21542151最後に成功したパターンマッチングで対応する括弧のサブパターンにマッチングした
21552152文字列が入っているが、既に抜けてしまったブロックでの
21562153パターンマッチングは勘定に入れません。
21572154
21582155=begin original
21592156
21602157Note there is a distinction between a capture buffer which matches
21612158the empty string a capture buffer which is optional. Eg, C<(x?)> and
21622159C<(x)?> The latter may be undef, the former not.
21632160
21642161=end original
21652162
21662163空文字列にマッチングする捕捉バッファと、オプションの捕捉バッファの
21672164違いに注意してください。
21682165例えば、C<(x?)> と C<(x)?> では、後者は undef かもしれませんが、
21692166前者は違います。
21702167
21712168=begin original
21722169
21732170These variables are read-only and dynamically-scoped.
21742171
21752172=end original
21762173
21772174これらの変数はすべて読み込み専用で、動的なスコープを持ちます。
21782175
21792176=begin original
21802177
21812178Mnemonic: like \digits.
21822179
21832180=end original
21842181
21852182記憶法: \(数字) のようなもの。
21862183
21872184=item @{^CAPTURE}
21882185X<@{^CAPTURE}> X<@^CAPTURE>
21892186
21902187=begin original
21912188
21922189An array which exposes the contents of the capture buffers, if any, of
21932190the last successful pattern match, not counting patterns matched
21942191in nested blocks that have been exited already.
21952192
21962193=end original
21972194
21982195最後に成功したパターンマッチングの (もしあれば) 捕捉バッファの内容を
21992196露出させた配列; 既に終了したネストしたブロックの中でマッチングしたパターンは
22002197考慮しません。
22012198
22022199=begin original
22032200
22042201Note that the 0 index of @{^CAPTURE} is equivalent to $1, the 1 index
22052202is equivalent to $2, etc.
22062203
22072204=end original
22082205
22092206@{^CAPTURE} の添え字 0 は $1 と等価、
22102207添え字 1 は $2 と等価、などであることに注意してください。
22112208
22122209 if ("foal"=~/(.)(.)(.)(.)/) {
22132210 print join "-", @{^CAPTURE};
22142211 }
22152212
22162213=begin original
22172214
22182215should output "f-o-a-l".
22192216
22202217=end original
22212218
22222219これは "f-o-a-l" を出力します。
22232220
22242221=begin original
22252222
2226See also L<<< /$<I<digits>> ($1, $2, ...) >>>, L</%{^CAPTURE}> and
2223See also L</$I<digits>>, L</%{^CAPTURE}> and L</%{^CAPTURE_ALL}>.
2227L</%{^CAPTURE_ALL}>.
22282224
22292225=end original
22302226
2231L<<< /$<I<数字>> ($1, $2, ...) >>>, L</%{^CAPTURE}>,
2227L</$I<digits>>, L</%{^CAPTURE}>, L</%{^CAPTURE_ALL}> も参照してください。
2232L</%{^CAPTURE_ALL}> も参照してください。
22332228
22342229=begin original
22352230
22362231Note that unlike most other regex magic variables there is no single
22372232letter equivalent to C<@{^CAPTURE}>.
22382233
22392234=end original
22402235
22412236その他のほとんどの正規表現マジカル変数と異なり、
22422237C<@{^CAPTURE}> と等価な単一文字変数はないことに注意してください。
22432238
22442239=begin original
22452240
22462241This variable was added in 5.25.7
22472242
22482243=end original
22492244
22502245これは 5.25.7 で追加されました。
22512246
22522247=item $MATCH
22532248
22542249=item $&
22552250X<$&> X<$MATCH>
22562251
22572252=begin original
22582253
22592254The string matched by the last successful pattern match (not counting
22602255any matches hidden within a BLOCK or C<eval()> enclosed by the current
22612256BLOCK).
22622257
22632258=end original
22642259
22652260最後に成功したパターンマッチでマッチした文字列 (現在の BLOCK で囲まれた
22662261BLOCK や C<eval()> で隠れている部分でのマッチは勘定に入れません)。
22672262
22682263=begin original
22692264
22702265See L</Performance issues> above for the serious performance implications
22712266of using this variable (even once) in your code.
22722267
22732268=end original
22742269
22752270この変数を(一度でも)使うことによる重大な性能の問題については前述した
22762271L</Performance issues> を参照してください。
22772272
22782273=begin original
22792274
22802275This variable is read-only and dynamically-scoped.
22812276
22822277=end original
22832278
22842279この変数は読み込み専用で動的スコープを持ちます。
22852280
22862281=begin original
22872282
22882283Mnemonic: like C<&> in some editors.
22892284
22902285=end original
22912286
22922287記憶法: あるエディタの C<&> ようなもの。
22932288
22942289=item ${^MATCH}
22952290X<${^MATCH}>
22962291
22972292=begin original
22982293
22992294This is similar to C<$&> (C<$MATCH>) except that it does not incur the
23002295performance penalty associated with that variable.
23012296
23022297=end original
23032298
23042299これは C<$&> (C<$MATCH>) と同様ですが、この変数と関連付けられた性能上の
23052300ペナルティを被りません。
23062301
23072302=begin original
23082303
23092304See L</Performance issues> above.
23102305
23112306=end original
23122307
23132308前述した L</Performance issues> を参照してください。
23142309
23152310=begin original
23162311
23172312In Perl v5.18 and earlier, it is only guaranteed
23182313to return a defined value when the pattern was compiled or executed with
23192314the C</p> modifier. In Perl v5.20, the C</p> modifier does nothing, so
23202315C<${^MATCH}> does the same thing as C<$MATCH>.
23212316
23222317=end original
23232318
23242319Perl v5.18 以前では、パターンが C</p> 修飾子付きでコンパイルまたは実行された
23252320場合にのみ定義された値を返すことが保証されます。
23262321Perl v5.20 では、C</p> 修飾子は何もしないので、C<${^MATCH}> は C<$MATCH> と
23272322同じです。
23282323
23292324=begin original
23302325
23312326This variable was added in Perl v5.10.0.
23322327
23332328=end original
23342329
23352330この変数は Perl v5.10.0 で追加されました。
23362331
23372332=begin original
23382333
23392334This variable is read-only and dynamically-scoped.
23402335
23412336=end original
23422337
23432338この変数は読み込み専用で動的スコープを持ちます。
23442339
23452340=item $PREMATCH
23462341
23472342=item $`
23482343X<$`> X<$PREMATCH> X<${^PREMATCH}>
23492344
23502345=begin original
23512346
23522347The string preceding whatever was matched by the last successful
23532348pattern match, not counting any matches hidden within a BLOCK or C<eval>
23542349enclosed by the current BLOCK.
23552350
23562351=end original
23572352
23582353最後の成功したパターンマッチ (現在のBLOCK で囲まれた BLOCK や eval() に
23592354隠れている部分でのマッチは勘定に入れません) でマッチした部分の前の文字列。
23602355
23612356=begin original
23622357
23632358See L</Performance issues> above for the serious performance implications
23642359of using this variable (even once) in your code.
23652360
23662361=end original
23672362
23682363この変数を(一度でも)使うことによる重大な性能の問題については前述した
23692364L</Performance issues> を参照してください。
23702365
23712366=begin original
23722367
23732368This variable is read-only and dynamically-scoped.
23742369
23752370=end original
23762371
23772372この変数は読み込み専用で動的スコープを持ちます。
23782373
23792374=begin original
23802375
23812376Mnemonic: C<`> often precedes a quoted string.
23822377
23832378=end original
23842379
23852380記憶法: C<`> は多くの場合クォートされた文字列の前にある。
23862381
23872382=item ${^PREMATCH}
23882383X<$`> X<${^PREMATCH}>
23892384
23902385=begin original
23912386
23922387This is similar to C<$`> ($PREMATCH) except that it does not incur the
23932388performance penalty associated with that variable.
23942389
23952390=end original
23962391
23972392これは C<$`> ($PREMATCH) と同様ですが、この変数と関連付けられた性能上の
23982393ペナルティを被りません。
23992394
24002395=begin original
24012396
24022397See L</Performance issues> above.
24032398
24042399=end original
24052400
24062401前述した L</Performance issues> を参照してください。
24072402
24082403=begin original
24092404
24102405In Perl v5.18 and earlier, it is only guaranteed
24112406to return a defined value when the pattern was compiled or executed with
24122407the C</p> modifier. In Perl v5.20, the C</p> modifier does nothing, so
24132408C<${^PREMATCH}> does the same thing as C<$PREMATCH>.
24142409
24152410=end original
24162411
24172412Perl v5.18 以前では、パターンが C</p> 修飾子付きでコンパイルまたは実行された
24182413場合にのみ定義された値を返すことが保証されます。
24192414Perl v5.20 では、C</p> 修飾子は何もしないので、C<${^PREMATCH}> は
24202415C<$PREMATCH> と同じです。
24212416
24222417=begin original
24232418
24242419This variable was added in Perl v5.10.0.
24252420
24262421=end original
24272422
24282423この変数は Perl v5.10.0 で追加されました。
24292424
24302425=begin original
24312426
24322427This variable is read-only and dynamically-scoped.
24332428
24342429=end original
24352430
24362431この変数は読み込み専用で動的スコープを持ちます。
24372432
24382433=item $POSTMATCH
24392434
24402435=item $'
24412436X<$'> X<$POSTMATCH> X<${^POSTMATCH}> X<@->
24422437
24432438=begin original
24442439
24452440The string following whatever was matched by the last successful
24462441pattern match (not counting any matches hidden within a BLOCK or C<eval()>
24472442enclosed by the current BLOCK). Example:
24482443
24492444=end original
24502445
24512446最後の成功したパターンマッチ (現在のBLOCK で囲まれた BLOCK や eval() に
24522447隠れている部分でのマッチは勘定に入れない) でマッチした部分に続く文字列。
24532448例:
24542449
24552450=begin original
24562451
24572452 local $_ = 'abcdefghi';
24582453 /def/;
24592454 print "$`:$&:$'\n"; # prints abc:def:ghi
24602455
24612456=end original
24622457
24632458 local $_ = 'abcdefghi';
24642459 /def/;
24652460 print "$`:$&:$'\n"; # abc:def:ghi を表示
24662461
24672462=begin original
24682463
24692464See L</Performance issues> above for the serious performance implications
24702465of using this variable (even once) in your code.
24712466
24722467=end original
24732468
24742469この変数を(一度でも)使うことによる重大な性能の問題については前述した
24752470L</Performance issues> を参照してください。
24762471
24772472=begin original
24782473
24792474This variable is read-only and dynamically-scoped.
24802475
24812476=end original
24822477
24832478この変数は読み込み専用で動的スコープを持ちます。
24842479
24852480=begin original
24862481
24872482Mnemonic: C<'> often follows a quoted string.
24882483
24892484=end original
24902485
24912486記憶法: C<'> は多くの場合クォートされた文字列の後にある。
24922487
24932488=item ${^POSTMATCH}
24942489X<${^POSTMATCH}> X<$'> X<$POSTMATCH>
24952490
24962491=begin original
24972492
24982493This is similar to C<$'> (C<$POSTMATCH>) except that it does not incur the
24992494performance penalty associated with that variable.
25002495
25012496=end original
25022497
25032498これは C<$'> (C<$POSTMATCH>) と同様ですが、この変数と関連付けられた性能上の
25042499ペナルティを被りません。
25052500
25062501=begin original
25072502
25082503See L</Performance issues> above.
25092504
25102505=end original
25112506
25122507前述した L</Performance issues> を参照してください。
25132508
25142509=begin original
25152510
25162511In Perl v5.18 and earlier, it is only guaranteed
25172512to return a defined value when the pattern was compiled or executed with
25182513the C</p> modifier. In Perl v5.20, the C</p> modifier does nothing, so
25192514C<${^POSTMATCH}> does the same thing as C<$POSTMATCH>.
25202515
25212516=end original
25222517
25232518Perl v5.18 以前では、パターンが C</p> 修飾子付きでコンパイルまたは実行された
25242519場合にのみ定義された値を返すことが保証されます。
25252520Perl v5.20 では、C</p> 修飾子は何もしないので、C<${^POSTMATCH}> は
25262521C<$POSTMATCH> と同じです。
25272522
25282523=begin original
25292524
25302525This variable was added in Perl v5.10.0.
25312526
25322527=end original
25332528
25342529この変数は Perl v5.10.0 で追加されました。
25352530
25362531=begin original
25372532
25382533This variable is read-only and dynamically-scoped.
25392534
25402535=end original
25412536
25422537この変数は読み込み専用で動的スコープを持ちます。
25432538
25442539=item $LAST_PAREN_MATCH
25452540
25462541=item $+
25472542X<$+> X<$LAST_PAREN_MATCH>
25482543
25492544=begin original
25502545
2551The text matched by the highest used capture group of the last
2546The text matched by the last bracket of the last successful search pattern.
2552successful search pattern. It is logically equivalent to the highest
2553numbered capture variable (C<$1>, C<$2>, ...) which has a defined value.
2554
2555
2556=end original
2557
2558最後に検索されたパターンの最大の使われたの捕捉グループにマッチした文字列。
2559これはいくつかの選択肢の中でどれがマッチするのか
2560これは、定義されている最大の番号の捕捉変数
2561(C<$1>, C<$2>, ...) と論理的に等価です。
2562
2563=begin original
2564
25652547This is useful if you don't know which one of a set of alternative patterns
25662548matched. For example:
25672549
25682550=end original
25692551
2552最後に検索されたパターンの最後の括弧にマッチした文字列。
2553これはいくつかの選択肢の中でどれがマッチするのか
25702554わからないような場合に使うと便利です。
25712555例えば:
25722556
25732557 /Version: (.*)|Revision: (.*)/ && ($rev = $+);
25742558
25752559=begin original
25762560
25772561This variable is read-only and dynamically-scoped.
25782562
25792563=end original
25802564
25812565この変数は読み込み専用で動的スコープを持ちます。
25822566
25832567=begin original
25842568
25852569Mnemonic: be positive and forward looking.
25862570
25872571=end original
25882572
25892573記憶法: ポジティブで前向き。
25902574
25912575=item $LAST_SUBMATCH_RESULT
25922576
25932577=item $^N
25942578X<$^N> X<$LAST_SUBMATCH_RESULT>
25952579
25962580=begin original
25972581
25982582The text matched by the used group most-recently closed (i.e. the group
25992583with the rightmost closing parenthesis) of the last successful search
2600pattern. This is subtly different from C<$+>. For example in
2584pattern.
26012585
26022586=end original
26032587
26042588最近のマッチングに成功した検索パターンのうち、一番最近に閉じられた使われた
26052589グループ(つまり、一番右の閉じかっこのグループ)にマッチングしたテキスト。
2606これは C<$+> とわずかに異なります。
2607例えば次のものは
26082590
2609 "ab" =~ /^((.)(.))$/
2610
26112591=begin original
26122592
2613we have
2614
2615=end original
2616
2617次の結果になります
2618
2619 $1,$^N have the value "ab"
2620 $2 has the value "a"
2621 $3,$+ have the value "b"
2622
2623=begin original
2624
26252593This is primarily used inside C<(?{...})> blocks for examining text
26262594recently matched. For example, to effectively capture text to a variable
26272595(in addition to C<$1>, C<$2>, etc.), replace C<(...)> with
26282596
26292597=end original
26302598
26312599これは主として最近マッチしたテキストを調べるために C<(?{...})> ブロックの
26322600中で使われます。
26332601例えば、(C<$1>, C<$2> などに加えて) テキストを変数に効率的に捕捉するには、
26342602C<(...)> を以下で置き換えます:
26352603
26362604 (?:(...)(?{ $var = $^N }))
26372605
26382606=begin original
26392607
26402608By setting and then using C<$var> in this way relieves you from having to
26412609worry about exactly which numbered set of parentheses they are.
26422610
26432611=end original
26442612
26452613C<$var> をこの方法で設定してから使うことで、かっこの組の番号について
26462614気にしなくてすむようになります。
26472615
26482616=begin original
26492617
26502618This variable was added in Perl v5.8.0.
26512619
26522620=end original
26532621
26542622この変数は Perl v5.8.0 で追加されました。
26552623
26562624=begin original
26572625
26582626Mnemonic: the (possibly) Nested parenthesis that most recently closed.
26592627
26602628=end original
26612629
26622630記憶法: もっとも最近閉じられた、(おそらく) ネストした (Nested) かっこ。
26632631
26642632=item @LAST_MATCH_END
26652633
26662634=item @+
26672635X<@+> X<@LAST_MATCH_END>
26682636
26692637=begin original
26702638
26712639This array holds the offsets of the ends of the last successful
26722640submatches in the currently active dynamic scope. C<$+[0]> is
26732641the offset into the string of the end of the entire match. This
26742642is the same value as what the C<pos> function returns when called
26752643on the variable that was matched against. The I<n>th element
26762644of this array holds the offset of the I<n>th submatch, so
26772645C<$+[1]> is the offset past where C<$1> ends, C<$+[2]> the offset
26782646past where C<$2> ends, and so on. You can use C<$#+> to determine
26792647how many subgroups were in the last successful match. See the
26802648examples given for the C<@-> variable.
26812649
26822650=end original
26832651
26842652この配列は、現在アクティブな動的スコープで最後に成功した部分マッチングの
26852653最後へのオフセットを保持します。
26862654C<$+[0]> はマッチ全体の文字列の最後へのオフセットです。
26872655これはマッチした変数に対して C<pos> 関数を呼び出したときの返り値と同じです。
26882656この配列の I<n> 番目の要素は I<n> 番目のサブマッチのオフセットを
26892657保持しているので、C<$+[1]> は過去の C<$1> の終わりのオフセット、C<$+[2]> は
26902658C<$2> のオフセット、という形になります。
26912659C<$#+> は最後に成功したマッチでいくつサブグループがあるかを決定するのに
26922660使えます。
26932661C<@-> 変数の例を参照して下さい。
26942662
26952663=begin original
26962664
26972665This variable was added in Perl v5.6.0.
26982666
26992667=end original
27002668
27012669この変数は Perl v5.6.0 で追加されました。
27022670
27032671=item %{^CAPTURE}
27042672
27052673=item %LAST_PAREN_MATCH
27062674
27072675=item %+
27082676X<%+> X<%LAST_PAREN_MATCH> X<%{^CAPTURE}>
27092677
27102678=begin original
27112679
27122680Similar to C<@+>, the C<%+> hash allows access to the named capture
27132681buffers, should they exist, in the last successful match in the
27142682currently active dynamic scope.
27152683
27162684=end original
27172685
27182686C<@+> と同様、C<%+> ハッシュは、現在アクティブな動的スコープで最後に成功した
27192687マッチングの名前付き捕捉バッファ(存在すれば)へのアクセスを可能にします。
27202688
27212689=begin original
27222690
27232691For example, C<$+{foo}> is equivalent to C<$1> after the following match:
27242692
27252693=end original
27262694
27272695例えば、C<$+{foo}> は以下のマッチングの後の C<$1> と等価です:
27282696
27292697 'foo' =~ /(?<foo>foo)/;
27302698
27312699=begin original
27322700
27332701The keys of the C<%+> hash list only the names of buffers that have
27342702captured (and that are thus associated to defined values).
27352703
27362704=end original
27372705
27382706C<%+> ハッシュのキーは捕捉された(従って定義された値と結びついている)
27392707バッファの名前のみの一覧です。
27402708
27412709=begin original
27422710
27432711If multiple distinct capture groups have the same name, then
27442712C<$+{NAME}> will refer to the leftmost defined group in the match.
27452713
27462714=end original
27472715
27482716同じ名前の複数の異なる補足グループがある場合、
27492717C<$+{NAME}> はマッチングの中で一番左側に定義されているグループを
27502718参照します。
27512719
27522720=begin original
27532721
27542722The underlying behaviour of C<%+> is provided by the
27552723L<Tie::Hash::NamedCapture> module.
27562724
27572725=end original
27582726
27592727C<%+> の基礎となる振る舞いは L<Tie::Hash::NamedCapture> モジュールで
27602728提供されています。
27612729
27622730=begin original
27632731
27642732B<Note:> C<%-> and C<%+> are tied views into a common internal hash
27652733associated with the last successful regular expression. Therefore mixing
27662734iterative access to them via C<each> may have unpredictable results.
27672735Likewise, if the last successful match changes, then the results may be
27682736surprising.
27692737
27702738=end original
27712739
27722740B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の
27732741内部ハッシュと tie されたビューです。
27742742従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果となります。
27752743同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。
27762744
27772745=begin original
27782746
27792747This variable was added in Perl v5.10.0. The C<%{^CAPTURE}> alias was
27802748added in 5.25.7.
27812749
27822750=end original
27832751
27842752この変数は Perl v5.10.0 で追加されました。
27852753C<%{^CAPTURE}> の別名は 5.25.7 で追加されました。
27862754
27872755=begin original
27882756
27892757This variable is read-only and dynamically-scoped.
27902758
27912759=end original
27922760
27932761この変数は読み込み専用で動的スコープを持ちます。
27942762
27952763=item @LAST_MATCH_START
27962764
27972765=item @-
27982766X<@-> X<@LAST_MATCH_START>
27992767
28002768=begin original
28012769
28022770C<$-[0]> is the offset of the start of the last successful match.
2803C<$-[I<n>]> is the offset of the start of the substring matched by
2771C<$-[>I<n>C<]> is the offset of the start of the substring matched by
28042772I<n>-th subpattern, or undef if the subpattern did not match.
28052773
28062774=end original
28072775
28082776C<$-[0]> は最後に成功したマッチの先頭のオフセットです。
2809C<$-[I<n>]> は I<n> 番目のサブパターンにマッチした部分文字列の先頭の
2777C<$-[>I<n>C<]> は I<n> 番目のサブパターンにマッチした部分文字列の先頭の
28102778オフセットです; サブパターンがマッチしなかった場合は undef です。
28112779
28122780=begin original
28132781
28142782Thus, after a match against C<$_>, C<$&> coincides with C<substr $_, $-[0],
28152783$+[0] - $-[0]>. Similarly, $I<n> coincides with C<substr $_, $-[n],
28162784$+[n] - $-[n]> if C<$-[n]> is defined, and $+ coincides with
28172785C<substr $_, $-[$#-], $+[$#-] - $-[$#-]>. One can use C<$#-> to find the
28182786last matched subgroup in the last successful match. Contrast with
28192787C<$#+>, the number of subgroups in the regular expression. Compare
28202788with C<@+>.
28212789
28222790=end original
28232791
28242792従って C<$_> のマッチの後、C<$&> は C<substr $_, $-[0], $+[0] - $-[0]> と
28252793一致します。
28262794同様に、$I<n> は、C<$-[n]> が定義されていれば
28272795C<substr $_, $-[n], $+[n] - $-[n]> と一致し、
28282796$+ は C<substr $_, $-[$#-], $+[$#-] - $-[$#-]> と一致します。
28292797C<$#-> は直前に成功したマッチで最後のマッチしたサブグループを
28302798探すのに使えます。
28312799正規表現でのサブグループの数である C<$#+> と対照的です。
28322800C<@+> と比較してください。
28332801
28342802=begin original
28352803
28362804This array holds the offsets of the beginnings of the last
28372805successful submatches in the currently active dynamic scope.
28382806C<$-[0]> is the offset into the string of the beginning of the
28392807entire match. The I<n>th element of this array holds the offset
28402808of the I<n>th submatch, so C<$-[1]> is the offset where C<$1>
28412809begins, C<$-[2]> the offset where C<$2> begins, and so on.
28422810
28432811=end original
28442812
28452813この配列は現在アクティブな動的スコープ内で最後に成功した
28462814サブマッチの先頭位置のオフセットを保持します。
28472815C<$-[0]> はマッチ全体の先頭の文字列へのオフセットです。
28482816この配列の I<n> 番目の要素は I<n> 番目のサブマッチへの
28492817オフセットを保持しますので、C<$-[1]> は C<$1> の先頭への
28502818オフセット、C<$-[2]> は C<$2> の先頭へのオフセット、などとなります。
28512819
28522820=begin original
28532821
28542822After a match against some variable C<$var>:
28552823
28562824=end original
28572825
28582826ある変数 C<$var> でマッチした後、以下のようになります。
28592827
28602828=over 5
28612829
28622830=item C<$`> is the same as C<substr($var, 0, $-[0])>
28632831
28642832(C<$`> は C<substr($var, 0, $-[0])> と同じです)
28652833
28662834=item C<$&> is the same as C<substr($var, $-[0], $+[0] - $-[0])>
28672835
28682836(C<$&> は C<substr($var, $-[0], $+[0] - $-[0])> と同じです)
28692837
28702838=item C<$'> is the same as C<substr($var, $+[0])>
28712839
28722840(C<$'> は C<substr($var, $+[0])> と同じです)
28732841
28742842=item C<$1> is the same as C<substr($var, $-[1], $+[1] - $-[1])>
28752843
28762844(C<$1> は C<substr($var, $-[1], $+[1] - $-[1])> と同じです)
28772845
28782846=item C<$2> is the same as C<substr($var, $-[2], $+[2] - $-[2])>
28792847
28802848(C<$2> は C<substr($var, $-[2], $+[2] - $-[2])> と同じです)
28812849
28822850=item C<$3> is the same as C<substr($var, $-[3], $+[3] - $-[3])>
28832851
28842852(C<$3> は C<substr $var, $-[3], $+[3] - $-[3])> と同じです)
28852853
28862854=back
28872855
28882856=begin original
28892857
28902858This variable was added in Perl v5.6.0.
28912859
28922860=end original
28932861
28942862この変数は Perl v5.6.0 で追加されました。
28952863
28962864=item %{^CAPTURE_ALL}
28972865X<%{^CAPTURE_ALL}>
28982866
28992867=item %-
29002868X<%->
29012869
29022870=begin original
29032871
29042872Similar to C<%+>, this variable allows access to the named capture groups
29052873in the last successful match in the currently active dynamic scope. To
29062874each capture group name found in the regular expression, it associates a
29072875reference to an array containing the list of values captured by all
29082876buffers with that name (should there be several of them), in the order
29092877where they appear.
29102878
29112879=end original
29122880
29132881C<%+> と同様、この変数は現在アクティブな動的スコープで最後に成功した
29142882マッチングの名前付き捕捉グループへのアクセスを可能にします。
29152883正規表現中に捕捉グループ名が現れるごとに、その名前のグループ全てで
29162884(複数あるでしょう)捕捉されている値のリストを出現順で含む配列への
29172885リファレンスと関連付けられます。
29182886
29192887=begin original
29202888
29212889Here's an example:
29222890
29232891=end original
29242892
29252893以下は例です:
29262894
29272895 if ('1234' =~ /(?<A>1)(?<B>2)(?<A>3)(?<B>4)/) {
29282896 foreach my $bufname (sort keys %-) {
29292897 my $ary = $-{$bufname};
29302898 foreach my $idx (0..$#$ary) {
29312899 print "\$-{$bufname}[$idx] : ",
29322900 (defined($ary->[$idx])
29332901 ? "'$ary->[$idx]'"
29342902 : "undef"),
29352903 "\n";
29362904 }
29372905 }
29382906 }
29392907
29402908=begin original
29412909
29422910would print out:
29432911
29442912=end original
29452913
29462914とすると、以下のものが表示されます:
29472915
29482916 $-{A}[0] : '1'
29492917 $-{A}[1] : '3'
29502918 $-{B}[0] : '2'
29512919 $-{B}[1] : '4'
29522920
29532921=begin original
29542922
29552923The keys of the C<%-> hash correspond to all buffer names found in
29562924the regular expression.
29572925
29582926=end original
29592927
29602928C<%-> ハッシュのキーは正規表現で見つかった全てのバッファ名に対応します。
29612929
29622930=begin original
29632931
29642932The behaviour of C<%-> is implemented via the
29652933L<Tie::Hash::NamedCapture> module.
29662934
29672935=end original
29682936
29692937C<%-> の振る舞いは L<Tie::Hash::NamedCapture> モジュールを使って
29702938実装されています。
29712939
29722940=begin original
29732941
29742942B<Note:> C<%-> and C<%+> are tied views into a common internal hash
29752943associated with the last successful regular expression. Therefore mixing
29762944iterative access to them via C<each> may have unpredictable results.
29772945Likewise, if the last successful match changes, then the results may be
29782946surprising.
29792947
29802948=end original
29812949
29822950B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の
29832951内部ハッシュと tie されたビューです。
29842952従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果となります。
29852953同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。
29862954
29872955=begin original
29882956
29892957This variable was added in Perl v5.10.0. The C<%{^CAPTURE_ALL}> alias was
29902958added in 5.25.7.
29912959
29922960=end original
29932961
29942962この変数は Perl v5.10.0 で追加されました。
29952963C<%{^CAPTURE_ALL}> の別名は 5.25.7 で追加されました。
29962964
29972965=begin original
29982966
29992967This variable is read-only and dynamically-scoped.
30002968
30012969=end original
30022970
30032971この変数は読み込み専用で動的スコープを持ちます。
30042972
30052973=item $LAST_REGEXP_CODE_RESULT
30062974
30072975=item $^R
30082976X<$^R> X<$LAST_REGEXP_CODE_RESULT>
30092977
30102978=begin original
30112979
30122980The result of evaluation of the last successful C<(?{ code })>
30132981regular expression assertion (see L<perlre>). May be written to.
30142982
30152983=end original
30162984
30172985最後に成功した C<(?{ code })> 正規表現アサートの評価の結果です
30182986(L<perlre> を参照して下さい)。おそらくもっと書き足します。
30192987
30202988=begin original
30212989
30222990This variable was added in Perl 5.005.
30232991
30242992=end original
30252993
30262994この変数は Perl 5.005 で追加されました。
30272995
3028=item ${^RE_COMPILE_RECURSION_LIMIT}
3029X<${^RE_COMPILE_RECURSION_LIMIT}>
3030
3031=begin original
3032
3033The current value giving the maximum number of open but unclosed
3034parenthetical groups there may be at any point during a regular
3035expression compilation. The default is currently 1000 nested groups.
3036You may adjust it depending on your needs and the amount of memory
3037available.
3038
3039=end original
3040
3041正規表現コンパイル中の任意の時点での開いているけれども閉じていない
3042かっこグループの最大値として与えられている現在の値。
3043デフォルトは現在の所 1000 ネストグループです。
3044これは必要性と利用可能なメモリ量に合わせて調整できます。
3045
3046=begin original
3047
3048This variable was added in Perl v5.30.0.
3049
3050=end original
3051
3052この変数は Perl v5.30.0 で追加されました。
3053
30542996=item ${^RE_DEBUG_FLAGS}
30552997X<${^RE_DEBUG_FLAGS}>
30562998
30572999=begin original
30583000
30593001The current value of the regex debugging flags. Set to 0 for no debug output
30603002even when the C<re 'debug'> module is loaded. See L<re> for details.
30613003
30623004=end original
30633005
30643006正規表現デバッグフラグの現在の値です。
306530070 をセットすると、C<re 'debug'> モジュールが読み込まれていてもデバッグ出力を
30663008行いません。
30673009詳細については L<re> を参照してください。
30683010
30693011=begin original
30703012
30713013This variable was added in Perl v5.10.0.
30723014
30733015=end original
30743016
30753017この変数は Perl v5.10.0 で追加されました。
30763018
30773019=item ${^RE_TRIE_MAXBUF}
30783020X<${^RE_TRIE_MAXBUF}>
30793021
30803022=begin original
30813023
30823024Controls how certain regex optimisations are applied and how much memory they
30833025utilize. This value by default is 65536 which corresponds to a 512kB
30843026temporary cache. Set this to a higher value to trade
30853027memory for speed when matching large alternations. Set
30863028it to a lower value if you want the optimisations to
30873029be as conservative of memory as possible but still occur, and set it to a
30883030negative value to prevent the optimisation and conserve the most memory.
30893031Under normal situations this variable should be of no interest to you.
30903032
30913033=end original
30923034
30933035どれくらい正規表現の最適化を行い、どれくらいのメモリを利用するかを制御します。
30943036デフォルトではこの値は 65536 で、512kB の一時キャッシュに相当します。
30953037この値を大きくすると、大きなものとマッチングするときに速度を重視して多くの
30963038メモリを使います。
30973039もしできるだけ保守的なメモリ消費をするけれども使うこともある、というように
30983040最適化したい場合は小さい値を設定します; 負の値を設定すると最適化は行わず、
30993041最大限メモリを節約します。
31003042通常の状況では、この変数はあなたの興味を引くものではないでしょう。
31013043
31023044=begin original
31033045
31043046This variable was added in Perl v5.10.0.
31053047
31063048=end original
31073049
31083050この変数は Perl v5.10.0 で追加されました。
31093051
31103052=back
31113053
31123054=head2 Variables related to filehandles
31133055
31143056(ファイルハンドル関連の変数)
31153057
31163058=begin original
31173059
31183060Variables that depend on the currently selected filehandle may be set
31193061by calling an appropriate object method on the C<IO::Handle> object,
31203062although this is less efficient than using the regular built-in
31213063variables. (Summary lines below for this contain the word HANDLE.)
31223064First you must say
31233065
31243066=end original
31253067
31263068現在選択されているファイルハンドルに依存する変数の場合には、代わりに
31273069C<IO::Handle> オブジェクトに関するオブジェクトメソッドを呼び出して
31283070設定できますが、通常の組み込み変数よりは効率が落ちます。
31293071(以下の要約では HANDLE という語を含んでいます。)
31303072まず最初に必ず、
31313073
31323074 use IO::Handle;
31333075
31343076=begin original
31353077
31363078after which you may use either
31373079
31383080=end original
31393081
31403082と書き、その後で以下のように書くか、
31413083
31423084 method HANDLE EXPR
31433085
31443086=begin original
31453087
31463088or more safely,
31473089
31483090=end original
31493091
31503092もしくはより安全に以下のように書きます:
31513093
31523094 HANDLE->method(EXPR)
31533095
31543096=begin original
31553097
31563098Each method returns the old value of the C<IO::Handle> attribute. The
31573099methods each take an optional EXPR, which, if supplied, specifies the
31583100new value for the C<IO::Handle> attribute in question. If not
31593101supplied, most methods do nothing to the current value--except for
31603102C<autoflush()>, which will assume a 1 for you, just to be different.
31613103
31623104=end original
31633105
31643106それぞれのメソッドは、C<IO::Handle> 属性の昔の値を返します。
31653107メソッドはそれぞれ EXPR をとることができ、指定した場合には、問題の
31663108C<IO::Handle> 属性の新しい値を指定することになります。
31673109指定しない場合には、多くのメソッドでは現在の値に対して何もしませんが、
31683110C<autoflush()> では 1 を指定されたものとします。
31693111
31703112=begin original
31713113
31723114Because loading in the C<IO::Handle> class is an expensive operation,
31733115you should learn how to use the regular built-in variables.
31743116
31753117=end original
31763118
31773119C<IO::Handle> クラスを読み込むのはコストの高い操作なので、
31783120通常の組み込み変数の使い方を覚えるべきです。
31793121
31803122=begin original
31813123
31823124A few of these variables are considered "read-only". This means that
31833125if you try to assign to this variable, either directly or indirectly
31843126through a reference, you'll raise a run-time exception.
31853127
31863128=end original
31873129
31883130これらの変数のいくつかは「読み込み専用」と考えられます。
31893131つまり、もしこの変数に対して直接またはリファレンスを通して間接に
31903132代入しようとすると、、実行時エラーが発生します。
31913133
31923134=begin original
31933135
31943136You should be very careful when modifying the default values of most
31953137special variables described in this document. In most cases you want
31963138to localize these variables before changing them, since if you don't,
31973139the change may affect other modules which rely on the default values
31983140of the special variables that you have changed. This is one of the
31993141correct ways to read the whole file at once:
32003142
32013143=end original
32023144
32033145この文書に記述されているほとんどの特殊変数のデフォルト値を変更するときには
32043146とても慎重になるべきです。
32053147ほとんどの場合、これらの変数を変更する前にこれらをローカル化したいでしょう;
32063148さもなければ、あなたが変更した特殊変数のデフォルト値に依存している
32073149その他のモジュールにも影響を与えるかもしれないからです。
32083150これはファイル全体を一度に読み込む正しい方法の一つです:
32093151
32103152=begin original
32113153
32123154 open my $fh, "<", "foo" or die $!;
32133155 local $/; # enable localized slurp mode
32143156 my $content = <$fh>;
32153157 close $fh;
32163158
32173159=end original
32183160
32193161 open my $fh, "<", "foo" or die $!;
32203162 local $/; # ローカル化された吸い込みモードを有効にする
32213163 my $content = <$fh>;
32223164 close $fh;
32233165
32243166=begin original
32253167
32263168But the following code is quite bad:
32273169
32283170=end original
32293171
32303172しかし以下のコードは完全に悪いものです:
32313173
32323174=begin original
32333175
32343176 open my $fh, "<", "foo" or die $!;
32353177 undef $/; # enable slurp mode
32363178 my $content = <$fh>;
32373179 close $fh;
32383180
32393181=end original
32403182
32413183 open my $fh, "<", "foo" or die $!;
32423184 undef $/; # 吸い込みモードを有効にする
32433185 my $content = <$fh>;
32443186 close $fh;
32453187
32463188=begin original
32473189
32483190since some other module, may want to read data from some file in the
32493191default "line mode", so if the code we have just presented has been
32503192executed, the global value of C<$/> is now changed for any other code
32513193running inside the same Perl interpreter.
32523194
32533195=end original
32543196
32553197なぜなら、その他のモジュールでは、デフォルトの「行モード」でファイルを
32563198読もうとするかも知れませんが、もし単に前述のコードを実行すると、
32573199C<$/> のグローバルな値が、同じ Perl インタプリタ内で実行される
32583200その他のコードに対しても変更されるからです。
32593201
32603202=begin original
32613203
32623204Usually when a variable is localized you want to make sure that this
32633205change affects the shortest scope possible. So unless you are already
32643206inside some short C<{}> block, you should create one yourself. For
32653207example:
32663208
32673209=end original
32683210
32693211通常、変数をローカル化するとき、この変更ができるだけ最短のスコープに
32703212影響を与えることを確実にしたいでしょう。
32713213従って、既に小さい C<{}> ブロックの内側であるのでない限り、それを
32723214自身で作るべきです。
32733215例えば:
32743216
32753217 my $content = '';
32763218 open my $fh, "<", "foo" or die $!;
32773219 {
32783220 local $/;
32793221 $content = <$fh>;
32803222 }
32813223 close $fh;
32823224
32833225=begin original
32843226
32853227Here is an example of how your own code can go broken:
32863228
32873229=end original
32883230
32893231以下はどのように自分のコードが壊れるかの例です:
32903232
32913233 for ( 1..3 ){
32923234 $\ = "\r\n";
32933235 nasty_break();
32943236 print "$_";
32953237 }
32963238
32973239=begin original
32983240
32993241 sub nasty_break {
33003242 $\ = "\f";
33013243 # do something with $_
33023244 }
33033245
33043246=end original
33053247
33063248 sub nasty_break {
33073249 $\ = "\f";
33083250 # $_ で何かする
33093251 }
33103252
33113253=begin original
33123254
33133255You probably expect this code to print the equivalent of
33143256
33153257=end original
33163258
33173259おそらくこのコードは以下のように表示されることを期待しています:
33183260
33193261 "1\r\n2\r\n3\r\n"
33203262
33213263=begin original
33223264
33233265but instead you get:
33243266
33253267=end original
33263268
33273269しかし、以下のようになります:
33283270
33293271 "1\f2\f3\f"
33303272
33313273=begin original
33323274
33333275Why? Because C<nasty_break()> modifies C<$\> without localizing it
33343276first. The value you set in C<nasty_break()> is still there when you
33353277return. The fix is to add C<local()> so the value doesn't leak out of
33363278C<nasty_break()>:
33373279
33383280=end original
33393281
33403282なぜでしょう?
33413283C<nasty_break()> は C<$_> をローカル化する前に変更するからです。
33423284C<nasty_break()> で設定した値は戻ったときにまだそこにあります。
33433285修正するには、C<local()> を追加して、値が C<nasty_break()> の外に
33443286漏れないようにします:
33453287
33463288 local $\ = "\f";
33473289
33483290=begin original
33493291
33503292It's easy to notice the problem in such a short example, but in more
33513293complicated code you are looking for trouble if you don't localize
33523294changes to the special variables.
33533295
33543296=end original
33553297
33563298このような短い例では問題に気付くのは簡単ですが、より複雑なコードでは、
33573299もし特殊変数の変更をローカル化していないと問題を探すことになります。
33583300
33593301=over 8
33603302
33613303=item $ARGV
33623304X<$ARGV>
33633305
33643306=begin original
33653307
33663308Contains the name of the current file when reading from C<< <> >>.
33673309
33683310=end original
33693311
33703312C<< <> >> から読込みを行なっているとき、その時点のファイル名を示します。
33713313
33723314=item @ARGV
33733315X<@ARGV>
33743316
33753317=begin original
33763318
33773319The array C<@ARGV> contains the command-line arguments intended for
33783320the script. C<$#ARGV> is generally the number of arguments minus
33793321one, because C<$ARGV[0]> is the first argument, I<not> the program's
33803322command name itself. See L</$0> for the command name.
33813323
33823324=end original
33833325
33843326配列 C<@ARGV> は、コマンドラインからスクリプトに渡す引数が入れられます。
33853327C<$ARGV[0]> がI<プログラムのコマンド名自身ではなく>、
33863328最初の引数ですから、C<$#ARGV> は一般には、引数の個数 - 1 となります。
33873329コマンド名については、L</$0> を参照してください。
33883330
33893331=item ARGV
33903332X<ARGV>
33913333
33923334=begin original
33933335
33943336The special filehandle that iterates over command-line filenames in
33953337C<@ARGV>. Usually written as the null filehandle in the angle operator
33963338C<< <> >>. Note that currently C<ARGV> only has its magical effect
33973339within the C<< <> >> operator; elsewhere it is just a plain filehandle
33983340corresponding to the last file opened by C<< <> >>. In particular,
33993341passing C<\*ARGV> as a parameter to a function that expects a filehandle
34003342may not cause your function to automatically read the contents of all the
34013343files in C<@ARGV>.
34023344
34033345=end original
34043346
34053347C<@ARGV> にあるコマンドラインで指定されたファイル名に対して反復する
34063348特殊ファイルハンドルです。
34073349通常角かっこ C<< <> >> の中で空ファイルハンドルとして書かれます。
34083350現在のところ、C<ARGV> は C<< <> >> 演算子の中でのみ特別な効果があることに
34093351注意してください; その他の場所では、C<< <> >> で開かれた最後のファイルに
34103352対応する普通のファイルハンドルです。
34113353特に、ファイルハンドルを想定している関数に C<\*ARGV> を引数として渡しても、
34123354関数内で C<@ARGV> にある全てのファイルの内容を自動的に読み込むことには
34133355なりません。
34143356
34153357=item ARGVOUT
34163358X<ARGVOUT>
34173359
34183360=begin original
34193361
34203362The special filehandle that points to the currently open output file
34213363when doing edit-in-place processing with B<-i>. Useful when you have
34223364to do a lot of inserting and don't want to keep modifying C<$_>. See
34233365L<perlrun> for the B<-i> switch.
34243366
34253367=end original
34263368
34273369B<-i> を使ってその場修正を行っているときに、現在開いている出力ファイルを
34283370示す特殊ファイルハンドルです。
34293371たくさんの挿入をする必要があるときに C<$_> を修正し続けたくない場合に有用です。
34303372B<-i> オプションについては L<perlrun> を参照してください。
34313373
34323374=item IO::Handle->output_field_separator( EXPR )
34333375
34343376=item $OUTPUT_FIELD_SEPARATOR
34353377
34363378=item $OFS
34373379
34383380=item $,
34393381X<$,> X<$OFS> X<$OUTPUT_FIELD_SEPARATOR>
34403382
34413383=begin original
34423384
34433385The output field separator for the print operator. If defined, this
34443386value is printed between each of print's arguments. Default is C<undef>.
34453387
34463388=end original
34473389
34483390print 演算子のための出力フィールドセパレータ。
34493391定義されると、この値がそれぞれの print の引数の間に表示されます。
34503392デフォルトは C<undef> です。
34513393
34523394=begin original
34533395
34543396You cannot call C<output_field_separator()> on a handle, only as a
34553397static method. See L<IO::Handle|IO::Handle>.
34563398
34573399=end original
34583400
34593401ハンドルに対して C<output_field_separator()> を呼び出すことはできません;
34603402静的メソッドしてのみです。
34613403L<IO::Handle|IO::Handle> を参照してください。
34623404
34633405=begin original
34643406
34653407Mnemonic: what is printed when there is a "," in your print statement.
34663408
34673409=end original
34683410
34693411記憶法: print 文で "," を書いた場所に印字されるもの。
34703412
34713413=item HANDLE->input_line_number( EXPR )
34723414
34733415=item $INPUT_LINE_NUMBER
34743416
34753417=item $NR
34763418
34773419=item $.
34783420X<$.> X<$NR> X<$INPUT_LINE_NUMBER> X<line number>
34793421
34803422=begin original
34813423
34823424Current line number for the last filehandle accessed.
34833425
34843426=end original
34853427
34863428最後にアクセスされたファイルハンドルの現在の行番号。
34873429
34883430=begin original
34893431
34903432Each filehandle in Perl counts the number of lines that have been read
34913433from it. (Depending on the value of C<$/>, Perl's idea of what
34923434constitutes a line may not match yours.) When a line is read from a
34933435filehandle (via C<readline()> or C<< <> >>), or when C<tell()> or
34943436C<seek()> is called on it, C<$.> becomes an alias to the line counter
34953437for that filehandle.
34963438
34973439=end original
34983440
34993441Perl の各ファイルハンドルは、そこから読み込んだ行数を数えています。
35003442(C<$/> の値に依存して、何が行を構成するかに関する Perl の考えはあなたの
35013443考えと一致しないかもしれません。)
35023444行が(C<readline()> や C<< <> >> を使って)ファイルハンドルから読み込まれたか、
35033445C<tell()> や C<seek()> がファイルハンドルに対して呼び出された場合、
35043446C<$.> はそのファイルハンドルの行カウンタへのエイリアスとなります。
35053447
35063448=begin original
35073449
35083450You can adjust the counter by assigning to C<$.>, but this will not
35093451actually move the seek pointer. I<Localizing C<$.> will not localize
35103452the filehandle's line count>. Instead, it will localize perl's notion
35113453of which filehandle C<$.> is currently aliased to.
35123454
35133455=end original
35143456
35153457C<$.> へ代入することでカウンタの値を修正できますが、これは実際にシーク
35163458ポインタを動かすことはありません。
35173459I<C<$.> をローカル化してもファイルハンドルの行カウンタはローカル化されません>。
35183460代わりに、現在 C<$.> がどのファイルハンドルへのエイリアスかという情報が
35193461ローカル化されます。
35203462
35213463=begin original
35223464
35233465C<$.> is reset when the filehandle is closed, but B<not> when an open
35243466filehandle is reopened without an intervening C<close()>. For more
35253467details, see L<perlop/"IE<sol>O Operators">. Because C<< <> >> never does
35263468an explicit close, line numbers increase across C<ARGV> files (but see
35273469examples in L<perlfunc/eof>).
35283470
35293471=end original
35303472
35313473C<$.> はファイルハンドルがクローズされるとリセットされますが、
35323474オープンしているファイルハンドルが C<close()> されることなく再オープンされた
35333475場合にはリセット B<されません>。
35343476さらなる詳細については、L<perlop/"IE<sol>O Operators"> を参照してください。
35353477なぜなら、 C<< <> >> は決して明示的なクローズは行わず、行番号は C<ARGV> の
35363478ファイル間で通算してカウントされるからです(但し L<perlfunc/eof> の例を
35373479参照してください)。
35383480
35393481=begin original
35403482
35413483You can also use C<< HANDLE->input_line_number(EXPR) >> to access the
35423484line counter for a given filehandle without having to worry about
35433485which handle you last accessed.
35443486
35453487=end original
35463488
35473489また、C<< HANDLE->input_line_number(EXPR) >> とすることで、どのハンドルに
35483490最後にアクセスしたかを気にすることなく行カウンタにアクセスできます。
35493491
35503492=begin original
35513493
35523494Mnemonic: many programs use "." to mean the current line number.
35533495
35543496=end original
35553497
35563498記憶法: 多くのプログラムで "." が現在行番号を示すように使われています。
35573499
35583500=item IO::Handle->input_record_separator( EXPR )
35593501
35603502=item $INPUT_RECORD_SEPARATOR
35613503
35623504=item $RS
35633505
35643506=item $/
35653507X<$/> X<$RS> X<$INPUT_RECORD_SEPARATOR>
35663508
35673509=begin original
35683510
35693511The input record separator, newline by default. This influences Perl's
35703512idea of what a "line" is. Works like B<awk>'s RS variable, including
35713513treating empty lines as a terminator if set to the null string (an
35723514empty line cannot contain any spaces or tabs). You may set it to a
35733515multi-character string to match a multi-character terminator, or to
35743516C<undef> to read through the end of file. Setting it to C<"\n\n">
35753517means something slightly different than setting to C<"">, if the file
35763518contains consecutive empty lines. Setting to C<""> will treat two or
35773519more consecutive empty lines as a single empty line. Setting to
35783520C<"\n\n"> will blindly assume that the next input character belongs to
35793521the next paragraph, even if it's a newline.
35803522
35813523=end original
35823524
35833525入力レコードセパレータで、デフォルトでは改行文字。
35843526これは Perl での「行」とは何か、ということに影響を与えます。
35853527空文字列に設定されると、空行をセパレータとして扱うことを含めて、B<awk> の
35863528変数 RS のように働きます(空行はスペースやタブを含んでいてはいけません)。
35873529複数文字の区切文字を示すために、文字列を設定することもできます; また、
35883530ファイルの最後まで読み込むために undef を指定することもできます。
35893531この変数に C<"\n\n"> を設定すると、空行が続く場合において、
35903532C<""> を設定した場合とわずかに違う動作をするようになります。
35913533C<""> を設定した場合には、複数の空行も 1 つの空行であるかのように扱います。
35923534C<"\n\n"> を設定した場合には、単純に次の文字が (たとえ改行文字であっても)
35933535次の段落に含まれるものとして扱います。
35943536
35953537=begin original
35963538
35973539 local $/; # enable "slurp" mode
35983540 local $_ = <FH>; # whole file now here
35993541 s/\n[ \t]+/ /g;
36003542
36013543=end original
36023544
36033545 local $/; # 「吸い込み」モードを有効にする
36043546 local $_ = <FH>; # ファイル全体が入る
36053547 s/\n[ \t]+/ /g;
36063548
36073549=begin original
36083550
36093551Remember: the value of C<$/> is a string, not a regex. B<awk> has to
36103552be better for something. :-)
36113553
36123554=end original
36133555
36143556注意: C<$/> は文字列であり、正規表現ではありません。
36153557B<awk> は何かもっとうまくやらなくてはいけません。:-)
36163558
36173559=begin original
36183560
3619Setting C<$/> to an empty string -- the so-called I<paragraph mode> -- merits
3620special attention. When C<$/> is set to C<""> and the entire file is read in
3621with that setting, any sequence of consecutive newlines C<"\n\n"> at the
3622beginning of the file is discarded. With the exception of the final record in
3623the file, each sequence of characters ending in two or more newlines is
3624treated as one record and is read in to end in exactly two newlines. If the
3625last record in the file ends in zero or one consecutive newlines, that record
3626is read in with that number of newlines. If the last record ends in two or
3627more consecutive newlines, it is read in with two newlines like all preceding
3628records.
3629
3630=end original
3631
3632C<$/> に空文字列を設定すること -- I<段落モード> と呼ばれます -- には、
3633特に注意する価値があります。
3634C<$/> が C<""> に設定されて、ファイル全体がこの設定で読み込まれた場合、
3635ファイル先頭の連続する改行の並び C<"\n\n"> は捨てられます。
3636ファイルの最後のレコードを例外として、
3637二つ以上の改行で終わるそれぞれの文字並びは一つのレコードとして扱われ、
3638正確に二つの改行で終わるように読み込まれます。
3639ファイルの最後のレコードが 0 または 1 の連続する改行で終わっている場合、
3640そのレコードはその数の改行と共に読み込まれます。
3641最後のレコードが二つ以上の連続する改行で終わっている場合、
3642全ての先行するレコードと同様、二つの改行と共に読み込まれます。
3643
3644=begin original
3645
3646Suppose we wrote the following string to a file:
3647
3648=end original
3649
3650次の文字列をファイルに書いたとします:
3651
3652 my $string = "\n\n\n";
3653 $string .= "alpha beta\ngamma delta\n\n\n";
3654 $string .= "epsilon zeta eta\n\n";
3655 $string .= "theta\n";
3656
3657 my $file = 'simple_file.txt';
3658 open my $OUT, '>', $file or die;
3659 print $OUT $string;
3660 close $OUT or die;
3661
3662=begin original
3663
3664Now we read that file in paragraph mode:
3665
3666=end original
3667
3668このファイルを段落モードで読み込みます:
3669
3670 local $/ = ""; # paragraph mode
3671 open my $IN, '<', $file or die;
3672 my @records = <$IN>;
3673 close $IN or die;
3674
3675=begin original
3676
3677C<@records> will consist of these 3 strings:
3678
3679=end original
3680
3681C<@records> は三つの文字列からなります:
3682
3683 (
3684 "alpha beta\ngamma delta\n\n",
3685 "epsilon zeta eta\n\n",
3686 "theta\n",
3687 )
3688
3689=begin original
3690
36913561Setting C<$/> to a reference to an integer, scalar containing an
36923562integer, or scalar that's convertible to an integer will attempt to
36933563read records instead of lines, with the maximum record size being the
36943564referenced integer number of characters. So this:
36953565
36963566=end original
36973567
36983568C<$/> に整数、整数を含むスカラ、整数に変換できるスカラのいずれかへの
36993569リファレンスをセットすると、行を読む代わりにレコードを読もうとします;
37003570この場合、最大レコードサイズはリファレンス先の整数値の文字数となります。
37013571つまり:
37023572
37033573 local $/ = \32768; # or \"32768", or \$var_containing_32768
37043574 open my $fh, "<", $myfile or die $!;
37053575 local $_ = <$fh>;
37063576
37073577=begin original
37083578
37093579will read a record of no more than 32768 characters from $fh. If you're
37103580not reading from a record-oriented file (or your OS doesn't have
37113581record-oriented files), then you'll likely get a full chunk of data
37123582with every read. If a record is larger than the record size you've
37133583set, you'll get the record back in pieces. Trying to set the record
37143584size to zero or less is deprecated and will cause $/ to have the value
37153585of "undef", which will cause reading in the (rest of the) whole file.
37163586
37173587=end original
37183588
37193589これは $fh から 32768 文字を超えないようにレコードを読み込みます。
37203590もしレコード指向のファイルを読み込まない場合(あるいは OS がレコード指向
37213591ファイルを持たない場合)、読み込み毎にデータのチャンク全部を取り込みます。
37223592もしレコードがセットしたレコードサイズより大きい場合、
37233593レコードの部分を取り込みます。
37243594レコードサイズを 0 以下にセットしようとするのは廃止予定で、
37253595$/ に値 "undef" が設定され、(残りの)ファイル全体を読み込むことになります。
37263596
37273597=begin original
37283598
37293599As of 5.19.9 setting C<$/> to any other form of reference will throw a
37303600fatal exception. This is in preparation for supporting new ways to set
37313601C<$/> in the future.
37323602
37333603=end original
37343604
373536055.19.9 から、C<$/> にその他の形式のリファレンスを設定すると致命的エラーが
37363606投げられます。
37373607これは将来 C<$/> を設定する新しい方法に対応する準備です。
37383608
37393609=begin original
37403610
37413611On VMS only, record reads bypass PerlIO layers and any associated
37423612buffering, so you must not mix record and non-record reads on the
37433613same filehandle. Record mode mixes with line mode only when the
37443614same buffering layer is in use for both modes.
37453615
37463616=end original
37473617
37483618VMS だけでは、レコードは PerlIO 層とそれに関連するバッファリングを迂回して
37493619読み込まれるので、同じファイルハンドルでレコード読み込みと
37503620非レコード読み込みを混ぜてはいけません。
37513621レコードモードは、同じバッファリング層を両方のモードで使う場合にのみ
37523622ラインモードと混ざります。
37533623
37543624=begin original
37553625
37563626You cannot call C<input_record_separator()> on a handle, only as a
37573627static method. See L<IO::Handle|IO::Handle>.
37583628
37593629=end original
37603630
37613631ハンドルに対して C<input_record_separator()> を呼び出すことはできません;
37623632静的メソッドしてのみです。
37633633L<IO::Handle|IO::Handle> を参照してください。
37643634
37653635=begin original
37663636
37673637See also L<perlport/"Newlines">. Also see L</$.>.
37683638
37693639=end original
37703640
37713641L<perlport/"Newlines"> を参照してください。
37723642L</$.> も参照してください。
37733643
37743644=begin original
37753645
37763646Mnemonic: / delimits line boundaries when quoting poetry.
37773647
37783648=end original
37793649
37803650記憶法: /は、詩を引用するときに、行の区切りを示します。
37813651
37823652=item IO::Handle->output_record_separator( EXPR )
37833653
37843654=item $OUTPUT_RECORD_SEPARATOR
37853655
37863656=item $ORS
37873657
37883658=item $\
37893659X<$\> X<$ORS> X<$OUTPUT_RECORD_SEPARATOR>
37903660
37913661=begin original
37923662
37933663The output record separator for the print operator. If defined, this
37943664value is printed after the last of print's arguments. Default is C<undef>.
37953665
37963666=end original
37973667
37983668print 演算子のための出力レコードセパレータ。
37993669もし定義されていると、print の最後の引数の最後にこの値が表示されます。
38003670デフォルトは C<undef> です。
38013671
38023672=begin original
38033673
38043674You cannot call C<output_record_separator()> on a handle, only as a
38053675static method. See L<IO::Handle|IO::Handle>.
38063676
38073677=end original
38083678
38093679ハンドルに対して C<output_record_separator()> を呼び出すことはできません;
38103680静的メソッドしてのみです。
38113681L<IO::Handle|IO::Handle> を参照してください。
38123682
38133683=begin original
38143684
38153685Mnemonic: you set C<$\> instead of adding "\n" at the end of the print.
38163686Also, it's just like C<$/>, but it's what you get "back" from Perl.
38173687
38183688=end original
38193689
38203690記憶法: print の最後に "\n" を付け加える代わりに C<$\> を設定する。
38213691また、C<$/> に似通っているが、Perl から「バック」されるものです。
38223692
38233693=item HANDLE->autoflush( EXPR )
38243694
38253695=item $OUTPUT_AUTOFLUSH
38263696
38273697=item $|
38283698X<$|> X<autoflush> X<flush> X<$OUTPUT_AUTOFLUSH>
38293699
38303700=begin original
38313701
38323702If set to nonzero, forces a flush right away and after every write or
38333703print on the currently selected output channel. Default is 0
38343704(regardless of whether the channel is really buffered by the system or
38353705not; C<$|> tells you only whether you've asked Perl explicitly to
38363706flush after each write). STDOUT will typically be line buffered if
38373707output is to the terminal and block buffered otherwise. Setting this
38383708variable is useful primarily when you are outputting to a pipe or
38393709socket, such as when you are running a Perl program under B<rsh> and
38403710want to see the output as it's happening. This has no effect on input
38413711buffering. See L<perlfunc/getc> for that. See L<perlfunc/select> on
38423712how to select the output channel. See also L<IO::Handle>.
38433713
38443714=end original
38453715
384637160 以外に設定されると、その時点で選択されている出力チャネルを直ちにその場で
38473717フラッシュし、さらに write や print を行なうごとに、強制的にフラッシュします。
38483718デフォルトでは 0 となっています(チャンネルが実際にシステムによって
38493719バッファリングされているかどうかは関知しません。
38503720C<$|> は Perl が明示的に毎回書き込みの後にフラッシュするかどうかのみを
38513721示します)。
38523722STDOUT は通常では、端末への出力時には行バッファリング、
38533723それ以外ではブロックバッファリングであることに注意してください。
38543724これは、Perl のスクリプトを rsh 配下で実行して、実行状況を確認したい
38553725場合のように、パイプやソケットに出力するときに特に便利でしょう。
38563726これは入力バッファリングには何の影響も与えません。
38573727出力チャネルの選択方法については L<perlfunc/select> を参照してください。
38583728L<IO::Handle> も参照してください。
38593729
38603730=begin original
38613731
38623732Mnemonic: when you want your pipes to be piping hot.
38633733
38643734=end original
38653735
38663736記憶法: パイプをホットな状態にしておくために使う。
38673737
38683738=item ${^LAST_FH}
38693739X<${^LAST_FH}>
38703740
38713741=begin original
38723742
38733743This read-only variable contains a reference to the last-read filehandle.
38743744This is set by C<< <HANDLE> >>, C<readline>, C<tell>, C<eof> and C<seek>.
38753745This is the same handle that C<$.> and C<tell> and C<eof> without arguments
38763746use. It is also the handle used when Perl appends ", <STDIN> line 1" to
38773747an error or warning message.
38783748
38793749=end original
38803750
38813751この読み込み専用変数は最後に読み込んだファイルハンドルへのリファレンスを
38823752含んでいます。
38833753これは C<< <HANDLE> >>, C<readline>, C<tell>, C<eof>, C<seek> で
38843754設定されます。
38853755これは C<$.> および、C<tell> と C<eof> が引数なしで使われたときと同じ
38863756ハンドルです。
38873757これはまた、Perl がエラーまたは警告メッセージに ", <STDIN> line 1" を追加する
38883758ハンドルでもあります。
38893759
38903760=begin original
38913761
38923762This variable was added in Perl v5.18.0.
38933763
38943764=end original
38953765
38963766この変数は Perl v5.18.0 で追加されました。
38973767
38983768=back
38993769
39003770=head3 Variables related to formats
39013771
39023772(フォーマット関連の変数)
39033773
39043774=begin original
39053775
39063776The special variables for formats are a subset of those for
39073777filehandles. See L<perlform> for more information about Perl's
39083778formats.
39093779
39103780=end original
39113781
39123782フォーマットのための特殊変数はファイルハンドルのための物のサブセットです。
39133783Perl のフォーマットに関するさらなる情報については L<perlform> を
39143784参照してください。
39153785
39163786=over 8
39173787
39183788=item $ACCUMULATOR
39193789
39203790=item $^A
39213791X<$^A> X<$ACCUMULATOR>
39223792
39233793=begin original
39243794
39253795The current value of the C<write()> accumulator for C<format()> lines.
39263796A format contains C<formline()> calls that put their result into
39273797C<$^A>. After calling its format, C<write()> prints out the contents
39283798of C<$^A> and empties. So you never really see the contents of C<$^A>
39293799unless you call C<formline()> yourself and then look at it. See
39303800L<perlform> and L<perlfunc/"formline PICTURE,LIST">.
39313801
39323802=end original
39333803
39343804C<format()> 行のための、その時点での C<write()> アキュムレータの値。
39353805format には、C<$^A> に結果を残す、C<formline()> 呼び出しが含まれます。
39363806自分のフォーマットを呼び出した後で、
39373807C<write()> は C<$^A> の内容を出力してから消去します。
39383808したがって、自分で C<formline()> を呼び出すのでなければ、
39393809C<$^A> の値が見えることはありません。
39403810L<perlform> と L<perlfunc/"formline PICTURE,LIST"> を参照してください。
39413811
39423812=item IO::Handle->format_formfeed(EXPR)
39433813
39443814=item $FORMAT_FORMFEED
39453815
39463816=item $^L
39473817X<$^L> X<$FORMAT_FORMFEED>
39483818
39493819=begin original
39503820
39513821What formats output as a form feed. The default is C<\f>.
39523822
39533823=end original
39543824
39553825フォーマット出力で、改ページのために出力されるもの。
39563826デフォルトは C<\f>。
39573827
39583828=begin original
39593829
39603830You cannot call C<format_formfeed()> on a handle, only as a static
39613831method. See L<IO::Handle|IO::Handle>.
39623832
39633833=end original
39643834
39653835ハンドルに対して C<format_formfeed()> を呼び出すことはできません;
39663836静的メソッドしてのみです。
39673837L<IO::Handle|IO::Handle> を参照してください。
39683838
39693839=item HANDLE->format_page_number(EXPR)
39703840
39713841=item $FORMAT_PAGE_NUMBER
39723842
39733843=item $%
39743844X<$%> X<$FORMAT_PAGE_NUMBER>
39753845
39763846=begin original
39773847
39783848The current page number of the currently selected output channel.
39793849
39803850=end original
39813851
39823852その時点で選択されている出力チャネルの、その時点でのページ番号。
39833853
39843854=begin original
39853855
39863856Mnemonic: C<%> is page number in B<nroff>.
39873857
39883858=end original
39893859
39903860記憶法: C<%> は、B<nroff> でのページ番号です。
39913861
39923862=item HANDLE->format_lines_left(EXPR)
39933863
39943864=item $FORMAT_LINES_LEFT
39953865
39963866=item $-
39973867X<$-> X<$FORMAT_LINES_LEFT>
39983868
39993869=begin original
40003870
40013871The number of lines left on the page of the currently selected output
40023872channel.
40033873
40043874=end original
40053875
40063876その時点で選択されている出力チャネルの、ページに残っている行数。
40073877
40083878=begin original
40093879
40103880Mnemonic: lines_on_page - lines_printed.
40113881
40123882=end original
40133883
40143884記憶法: "ページ行数" - "印字済み行数"
40153885
40163886=item IO::Handle->format_line_break_characters EXPR
40173887
40183888=item $FORMAT_LINE_BREAK_CHARACTERS
40193889
40203890=item $:
40213891X<$:> X<FORMAT_LINE_BREAK_CHARACTERS>
40223892
40233893=begin original
40243894
40253895The current set of characters after which a string may be broken to
40263896fill continuation fields (starting with C<^>) in a format. The default is
40273897S<" \n-">, to break on a space, newline, or a hyphen.
40283898
40293899=end original
40303900
40313901フォーマットの充填継続フィールド (C<^> で始まるもの) への文字列で行分割を許す
40323902文字集合。
40333903デフォルトは S<" \n-"> で空白、改行、ハイフンの後で行分割が可能です。
40343904
40353905=begin original
40363906
40373907You cannot call C<format_line_break_characters()> on a handle, only as
40383908a static method. See L<IO::Handle|IO::Handle>.
40393909
40403910=end original
40413911
40423912ハンドルに対して C<format_line_break_characters()> を呼び出すことはできません;
40433913静的メソッドしてのみです。
40443914L<IO::Handle|IO::Handle> を参照してください。
40453915
40463916=begin original
40473917
40483918Mnemonic: a "colon" in poetry is a part of a line.
40493919
40503920=end original
40513921
40523922記憶法: 詩では「コロン」は、行の一部。
40533923
40543924=item HANDLE->format_lines_per_page(EXPR)
40553925
40563926=item $FORMAT_LINES_PER_PAGE
40573927
40583928=item $=
40593929X<$=> X<$FORMAT_LINES_PER_PAGE>
40603930
40613931=begin original
40623932
40633933The current page length (printable lines) of the currently selected
40643934output channel. The default is 60.
40653935
40663936=end original
40673937
40683938その時点で選択されている出力チャネルの、その時点でのページ長(印字可能行数)。
40693939デフォルトは 60 です。
40703940
40713941=begin original
40723942
40733943Mnemonic: = has horizontal lines.
40743944
40753945=end original
40763946
40773947記憶法: = には複数の水平線 (行) が含まれます。
40783948
40793949=item HANDLE->format_top_name(EXPR)
40803950
40813951=item $FORMAT_TOP_NAME
40823952
40833953=item $^
40843954X<$^> X<$FORMAT_TOP_NAME>
40853955
40863956=begin original
40873957
40883958The name of the current top-of-page format for the currently selected
40893959output channel. The default is the name of the filehandle with C<_TOP>
40903960appended. For example, the default format top name for the C<STDOUT>
40913961filehandle is C<STDOUT_TOP>.
40923962
40933963=end original
40943964
40953965その時点で選択されている出力チャネルの、その時点でのページ先頭フォーマット名。
40963966デフォルトは、ファイルハンドル名に _TOP を続けたものです。
40973967例えば、C<STDOUT> ファイルハンドルのデフォルトのページ先頭フォーマット名は
40983968C<STDOUT_TOP> です。
40993969
41003970=begin original
41013971
41023972Mnemonic: points to top of page.
41033973
41043974=end original
41053975
41063976記憶法: ページの先頭へのポインタ。
41073977
41083978=item HANDLE->format_name(EXPR)
41093979
41103980=item $FORMAT_NAME
41113981
41123982=item $~
41133983X<$~> X<$FORMAT_NAME>
41143984
41153985=begin original
41163986
41173987The name of the current report format for the currently selected
41183988output channel. The default format name is the same as the filehandle
41193989name. For example, the default format name for the C<STDOUT>
41203990filehandle is just C<STDOUT>.
41213991
41223992=end original
41233993
41243994その時点で選択されている出力チャネルの、その時点でのフォーマット名。
41253995デフォルトは、ファイルハンドル名です。
41263996例えば、C<STDOUT> ファイルハンドルのデフォルトフォーマット名は
41273997単に C<STDOUT> です。
41283998
41293999=begin original
41304000
41314001Mnemonic: brother to C<$^>.
41324002
41334003=end original
41344004
41354005記憶法: C<$^> の兄弟。
41364006
41374007=back
41384008
41394009=head2 Error Variables
41404010X<error> X<exception>
41414011
41424012(エラー変数)
41434013
41444014=begin original
41454015
41464016The variables C<$@>, C<$!>, C<$^E>, and C<$?> contain information
41474017about different types of error conditions that may appear during
41484018execution of a Perl program. The variables are shown ordered by
41494019the "distance" between the subsystem which reported the error and
41504020the Perl process. They correspond to errors detected by the Perl
41514021interpreter, C library, operating system, or an external program,
41524022respectively.
41534023
41544024=end original
41554025
41564026変数 C<$@>, C<$!>, C<$^E>, C<$?> は Perl プログラムの実行中に
41574027発生した、異なる種類のエラー情報を保持します。
41584028変数はエラーを報告した副システムと Perl プロセスとの「距離」の順番に
41594029並んでいます。
41604030これらはそれぞれ、Perl インタプリタ、C ライブラリ、
41614031オペレーティングシステム、外部プログラムによって検出された
41624032エラーに対応しています。
41634033
41644034=begin original
41654035
41664036To illustrate the differences between these variables, consider the
41674037following Perl expression, which uses a single-quoted string. After
41684038execution of this statement, perl may have set all four special error
41694039variables:
41704040
41714041=end original
41724042
41734043これらの変数の違いを示すために、
41744044以下のようなシングルクォートを用いた Perl 式を考えます。
41754045この文の実行後、perl は四つ全ての特殊エラー変数をセットします:
41764046
41774047 eval q{
41784048 open my $pipe, "/cdrom/install |" or die $!;
41794049 my @res = <$pipe>;
41804050 close $pipe or die "bad pipe: $?, $!";
41814051 };
41824052
41834053=begin original
41844054
41854055When perl executes the C<eval()> expression, it translates the
41864056C<open()>, C<< <PIPE> >>, and C<close> calls in the C run-time library
41874057and thence to the operating system kernel. perl sets C<$!> to
41884058the C library's C<errno> if one of these calls fails.
41894059
41904060=end original
41914061
41924062C<eval()> 式が実行されたとき、C<open()>, C<< <PIPE> >>, C<close> は
41934063C ランタイムライブラリの呼び出しに変換され、それからオペレーティング
41944064システムコールに変換されます。
41954065C<$!> はこれらの呼び出しのどれかが失敗したとき、
41964066C ライブラリの C<errno> の値がセットされます。
41974067
41984068=begin original
41994069
42004070C<$@> is set if the string to be C<eval>-ed did not compile (this may
42014071happen if C<open> or C<close> were imported with bad prototypes), or
42024072if Perl code executed during evaluation C<die()>d. In these cases the
42034073value of C<$@> is the compile error, or the argument to C<die> (which
42044074will interpolate C<$!> and C<$?>). (See also L<Fatal>, though.)
42054075
42064076=end original
42074077
42084078C<$@> は C<eval> された文字列がコンパイルされなかったとき(これは C<open> か
42094079C<close> が正しくないプロトタイプでインポートされたときに起こり得ます)、
42104080または評価中に実行している Perl コードが C<die()> したときにセットされます。
42114081これらの場合には C<$@> の値はコンパイルエラー、または
42124082C<die> への引数(これには C<$!> と C<$?> が差し挟まれます)です。
42134083(しかし、L<Fatal> も参照して下さい。)
42144084
42154085=begin original
42164086
42174087Under a few operating systems, C<$^E> may contain a more verbose error
42184088indicator, such as in this case, "CDROM tray not closed." Systems that
42194089do not support extended error messages leave C<$^E> the same as C<$!>.
42204090
42214091=end original
42224092
42234093いくつかのオペレーティングシステムでは、C<$^E> により詳細なエラー指示子が
42244094入っているかもしれません; 今回の場合で言えば、
42254095"CDROM tray not closed." などです。
42264096追加のエラーメッセージに対応していないシステムでは、C<$^E> は C<$!> と同じ
42274097値です。
42284098
42294099=begin original
42304100
42314101Finally, C<$?> may be set to a non-0 value if the external program
42324102F</cdrom/install> fails. The upper eight bits reflect specific error
42334103conditions encountered by the program (the program's C<exit()> value).
42344104The lower eight bits reflect mode of failure, like signal death and
42354105core dump information. See L<wait(2)> for details. In contrast to
42364106C<$!> and C<$^E>, which are set only if an error condition is detected,
42374107the variable C<$?> is set on each C<wait> or pipe C<close>,
42384108overwriting the old value. This is more like C<$@>, which on every
42394109C<eval()> is always set on failure and cleared on success.
42404110
42414111=end original
42424112
42434113最後に、C<$?> は外部プログラム F</cdrom/install> が失敗したときに
42444114非 0 にセットされるかもしれません。
42454115上位の 8 ビットはプログラムが遭遇した特定のエラー状況
42464116(プログラムの C<exit()> の値)を反映します。
42474117下位の 8 ビットは、シグナルの死亡やコアダンプ情報と言った失敗のモードを
42484118反映します。
42494119詳細については L<wait(2)> を参照して下さい。
42504120C<$!> と C<$^E> はエラー状況が検出されたときにのみ設定されますが、
42514121変数 C<$?> は C<wait> やパイプの C<close> の度に、前の値を上書きします。
42524122これは、C<$@> が C<eval()> の実行毎に、エラーならセットされ、
42534123成功ならクリアされるという動作と似ています。
42544124
42554125=begin original
42564126
42574127For more details, see the individual descriptions at C<$@>, C<$!>,
42584128C<$^E>, and C<$?>.
42594129
42604130=end original
42614131
42624132より詳細については、C<$@>, C<$!>, C<$^E>, C<$?> それぞれの説明を
42634133参照して下さい。
42644134
42654135=over 8
42664136
42674137=item ${^CHILD_ERROR_NATIVE}
42684138X<$^CHILD_ERROR_NATIVE>
42694139
42704140=begin original
42714141
42724142The native status returned by the last pipe close, backtick (C<``>)
42734143command, successful call to C<wait()> or C<waitpid()>, or from the
42744144C<system()> operator. On POSIX-like systems this value can be decoded
42754145with the WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED,
42764146WSTOPSIG and WIFCONTINUED functions provided by the L<POSIX> module.
42774147
42784148=end original
42794149
42804150最後のパイプクローズ、逆クォート (C<``>) コマンド、C<wait()> と
42814151C<waitpid()> の成功した呼び出し、C<system()> 演算子から返された、
42824152ネイティブなステータスです。
42834153POSIX 風システムでは、この値は L<POSIX> モジュールで提供される
42844154WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG,
42854155WIFCONTINUED 関数でデコードできます。
42864156
42874157=begin original
42884158
42894159Under VMS this reflects the actual VMS exit status; i.e. it is the
42904160same as C<$?> when the pragma C<use vmsish 'status'> is in effect.
42914161
42924162=end original
42934163
42944164VMS ではこれは実際の VMS の終了ステータスを反映します;
42954165言い換えると、これは C<use vmsish 'status'> プラグマが有効なときの $? と
42964166同じです。
42974167
42984168=begin original
42994169
43004170This variable was added in Perl v5.10.0.
43014171
43024172=end original
43034173
43044174この変数は Perl v5.10.0 で追加されました。
43054175
43064176=item $EXTENDED_OS_ERROR
43074177
43084178=item $^E
43094179X<$^E> X<$EXTENDED_OS_ERROR>
43104180
43114181=begin original
43124182
43134183Error information specific to the current operating system. At the
43144184moment, this differs from C<L</$!>> under only VMS, OS/2, and Win32 (and
43154185for MacPerl). On all other platforms, C<$^E> is always just the same
43164186as C<$!>.
43174187
43184188=end original
43194189
43204190現在のオペレーティングシステムに特化したエラー情報です。
43214191現在のところ、VMS, OS/2, Win32 (と MacPerl) のみで
43224192C<L</$!>> と異なる値をもちます。
43234193その他のプラットフォームでは、C<$^E> はいつも C<$!> と同じです。
43244194
43254195=begin original
43264196
43274197Under VMS, C<$^E> provides the VMS status value from the last system
43284198error. This is more specific information about the last system error
43294199than that provided by C<$!>. This is particularly important when C<$!>
43304200is set to B<EVMSERR>.
43314201
43324202=end original
43334203
43344204VMS では、C<$^E> は最後のシステムエラーの VMS ステータス値です。
43354205これは、最後のシステムエラーについて C<$!> で提供されるものより
43364206具体的な情報を示します。
43374207これは特に C<$!> が B<EVMSERR> にセットされた場合に重要です。
43384208
43394209=begin original
43404210
43414211Under OS/2, C<$^E> is set to the error code of the last call to OS/2
43424212API either via CRT, or directly from perl.
43434213
43444214=end original
43454215
43464216OS/2 では、C<$^E> は CRT 経由、または Perl から直接呼び出された
43474217最後の OS/2 API のエラーコードがセットされます。
43484218
43494219=begin original
43504220
43514221Under Win32, C<$^E> always returns the last error information reported
43524222by the Win32 call C<GetLastError()> which describes the last error
43534223from within the Win32 API. Most Win32-specific code will report errors
43544224via C<$^E>. ANSI C and Unix-like calls set C<errno> and so most
43554225portable Perl code will report errors via C<$!>.
43564226
43574227=end original
43584228
43594229Win32 では、C<$^E> は Win32 API での最後のエラーの内容を返す
43604230C<GetLastError()> Win32 呼び出しで報告される最新のエラー情報を
43614231返します。
43624232ほとんどの Win32 固有のコードはエラーを C<$^E> 経由で返します。
43634233ANSI C と Unix 風の呼び出しは C<errno> をセットするので、
43644234ほとんどの移植性のある Perl コードは C<$!> 経由で
43654235エラーを報告します。
43664236
43674237=begin original
43684238
43694239Caveats mentioned in the description of C<L</$!>> generally apply to
43704240C<$^E>, also.
43714241
43724242=end original
43734243
43744244C<L</$!>> の説明で触れた問題点は一般的に C<$^E> にも適用されます。
43754245
43764246=begin original
43774247
43784248This variable was added in Perl 5.003.
43794249
43804250=end original
43814251
43824252この変数は Perl 5.003 で追加されました。
43834253
43844254=begin original
43854255
43864256Mnemonic: Extra error explanation.
43874257
43884258=end original
43894259
43904260記憶法: 追加の(Extra)エラーの説明。
43914261
43924262=item $EXCEPTIONS_BEING_CAUGHT
43934263
43944264=item $^S
43954265X<$^S> X<$EXCEPTIONS_BEING_CAUGHT>
43964266
43974267=begin original
43984268
43994269Current state of the interpreter.
44004270
44014271=end original
44024272
44034273現在のインタプリタの状態を示します。
44044274
44054275=begin original
44064276
44074277 $^S State
44084278 --------- -------------------------------------
44094279 undef Parsing module, eval, or main program
44104280 true (1) Executing an eval
44114281 false (0) Otherwise
44124282
44134283=end original
44144284
44154285 $^S 状態
44164286 --------- -------------------
44174287 undef モジュール、eval、メインプログラムのパース中
44184288 真 (1) eval の実行中
44194289 偽 (0) その他
44204290
44214291=begin original
44224292
44234293The first state may happen in C<$SIG{__DIE__}> and C<$SIG{__WARN__}>
44244294handlers.
44254295
44264296=end original
44274297
44284298最初の状態は C<$SIG{__DIE__}> と C<$SIG{__WARN__}> のハンドラで起きる
44294299可能性があります。
44304300
44314301=begin original
44324302
44334303The English name $EXCEPTIONS_BEING_CAUGHT is slightly misleading, because
44344304the C<undef> value does not indicate whether exceptions are being caught,
44354305since compilation of the main program does not catch exceptions.
44364306
44374307=end original
44384308
44394309英語名 $EXCEPTIONS_BEING_CAUGHT は少し誤解を招きます; C<undef> は例外が
44404310捕捉されたかどうかを示しているわけではないからです; メインプログラムの
44414311コンパイルは例外を捕捉しません。
44424312
44434313=begin original
44444314
44454315This variable was added in Perl 5.004.
44464316
44474317=end original
44484318
44494319この変数は Perl 5.004 で追加されました。
44504320
44514321=item $WARNING
44524322
44534323=item $^W
44544324X<$^W> X<$WARNING>
44554325
44564326=begin original
44574327
44584328The current value of the warning switch, initially true if B<-w> was
44594329used, false otherwise, but directly modifiable.
44604330
44614331=end original
44624332
44634333警告スイッチの値で、B<-w> スイッチが使われると内部的に真となり、
44644334そうでない場合は直接変更可能です。
44654335
44664336=begin original
44674337
44684338See also L<warnings>.
44694339
44704340=end original
44714341
44724342L<warnings> も参照して下さい。
44734343
44744344=begin original
44754345
44764346Mnemonic: related to the B<-w> switch.
44774347
44784348=end original
44794349
44804350記憶法: B<-w> スイッチに関係します。
44814351
44824352=item ${^WARNING_BITS}
44834353X<${^WARNING_BITS}>
44844354
44854355=begin original
44864356
44874357The current set of warning checks enabled by the C<use warnings> pragma.
44884358It has the same scoping as the C<$^H> and C<%^H> variables. The exact
44894359values are considered internal to the L<warnings> pragma and may change
44904360between versions of Perl.
44914361
44924362=end original
44934363
44944364C<use warnings> プラグマで有効にされた、現在の警告チェックの集合です。
44954365C<$^H> および C<%^H> 変数と同じスコープを持ちます。
44964366正確な値は L<warnings> プラグマの内部の値と考えられ、Perl の
44974367バージョンによって変更されるかもしれません。
44984368
44994369=begin original
45004370
45014371This variable was added in Perl v5.6.0.
45024372
45034373=end original
45044374
45054375この変数は Perl v5.6.0 で追加されました。
45064376
45074377=item $OS_ERROR
45084378
45094379=item $ERRNO
45104380
45114381=item $!
45124382X<$!> X<$ERRNO> X<$OS_ERROR>
45134383
45144384=begin original
45154385
45164386When referenced, C<$!> retrieves the current value
45174387of the C C<errno> integer variable.
45184388If C<$!> is assigned a numerical value, that value is stored in C<errno>.
45194389When referenced as a string, C<$!> yields the system error string
45204390corresponding to C<errno>.
45214391
45224392=end original
45234393
45244394参照されると、C<$!> は C の C<errno> 整数変数の現在の値を取得します。
45254395C<$!> に数値が代入されると、その値は C<errno> に保管されます。
45264396文字列として参照されると、C<$!> は C<errno> に対応するシステムエラー
45274397文字列を返します。
45284398
45294399=begin original
45304400
45314401Many system or library calls set C<errno> if they fail,
45324402to indicate the cause of failure. They usually do B<not>
45334403set C<errno> to zero if they succeed. This means C<errno>,
45344404hence C<$!>, is meaningful only I<immediately> after a B<failure>:
45354405
45364406=end original
45374407
45384408多くのシステムやライブラリ呼び出しは、失敗したときに、失敗の理由を示すために
45394409C<errno> を設定します。
45404410これらは普通は成功したときには C<errno> にゼロを設定 B<しません>。
45414411これは、C<errno>、C<$!> は、B<失敗> の I<直後> でのみ意味が
45424412あるということです:
45434413
45444414=begin original
45454415
45464416 if (open my $fh, "<", $filename) {
45474417 # Here $! is meaningless.
45484418 ...
45494419 }
45504420 else {
45514421 # ONLY here is $! meaningful.
45524422 ...
45534423 # Already here $! might be meaningless.
45544424 }
45554425 # Since here we might have either success or failure,
45564426 # $! is meaningless.
45574427
45584428=end original
45594429
45604430 if (open my $fh, "<", $filename) {
45614431 # ここで $! は無意味。
45624432 ...
45634433 }
45644434 else {
45654435 # ここでだけ $! に意味がある。
45664436 ...
45674437 # ここで既に $! は無意味かもしれません。
45684438 }
45694439 # ここでは成功と失敗の両方の可能性があるので、
45704440 # $! は無意味。
45714441
45724442=begin original
45734443
45744444Here, I<meaningless> means that C<$!> may be unrelated to the outcome
45754445of the C<open()> operator. Assignment to C<$!> is similarly ephemeral.
45764446It can be used immediately before invoking the C<die()> operator,
45774447to set the exit value, or to inspect the system error string
45784448corresponding to error I<n>, or to restore C<$!> to a meaningful state.
45794449
45804450=end original
45814451
45824452ここで、I<無意味> というのは C<$!> は C<open()> 演算子の結果に
45834453関係ないということです。
45844454C<$!> への代入も同様に一時的なものです。
45854455これは、終了値を設定したり、エラー I<n> に対応するシステムエラー文字列を
45864456調べたり、C<$!> を意味のある状態に復元するために、C<die()> 演算子を
45874457起動する直前で使えます。
45884458
45894459=begin original
45904460
45914461Mnemonic: What just went bang?
45924462
45934463=end original
45944464
45954465記憶法: 何が bang(!) したか。
45964466
45974467=item %OS_ERROR
45984468
45994469=item %ERRNO
46004470
46014471=item %!
46024472X<%!> X<%OS_ERROR> X<%ERRNO>
46034473
46044474=begin original
46054475
46064476Each element of C<%!> has a true value only if C<$!> is set to that
46074477value. For example, C<$!{ENOENT}> is true if and only if the current
46084478value of C<$!> is C<ENOENT>; that is, if the most recent error was "No
46094479such file or directory" (or its moral equivalent: not all operating
46104480systems give that exact error, and certainly not all languages). The
46114481specific true value is not guaranteed, but in the past has generally
46124482been the numeric value of C<$!>. To check if a particular key is
46134483meaningful on your system, use C<exists $!{the_key}>; for a list of legal
46144484keys, use C<keys %!>. See L<Errno> for more information, and also see
46154485L</$!>.
46164486
46174487=end original
46184488
46194489C<%!> の各要素は、C<$!> がその値にセットされている場合にのみ真の値を持ちます。
46204490例えば、C<$!{ENOENT}> は、現在の C<$!> の値が C<ENOENT> の場合にのみ
46214491真となります; これは、最近のエラーが "No such file or directory" (あるいは
46224492倫理的に等価なもの: 全ての OS が正確に同じエラーを出すわけではないですし、
46234493全ての言語で出るわけでもありません) の場合です。
46244494特定の真の値は保証されませんが、以前は一般的には C<$!> の数値でした。
46254495あなたのシステムで特定のキーが意味があるかどうかを調べるには、
46264496C<exists $!{the_key}> を使ってください; 有効なキーのリストを得るには、
46274497C<keys %!> としてください。
46284498さらなる情報に関しては L<Errno> と C</$!> を参照してください。
46294499
46304500=begin original
46314501
46324502This variable was added in Perl 5.005.
46334503
46344504=end original
46354505
46364506この変数は Perl 5.005 で追加されました。
46374507
46384508=item $CHILD_ERROR
46394509
46404510=item $?
46414511X<$?> X<$CHILD_ERROR>
46424512
46434513=begin original
46444514
46454515The status returned by the last pipe close, backtick (C<``>) command,
46464516successful call to C<wait()> or C<waitpid()>, or from the C<system()>
46474517operator. This is just the 16-bit status word returned by the
46484518traditional Unix C<wait()> system call (or else is made up to look
46494519like it). Thus, the exit value of the subprocess is really (C<<< $? >>
465045208 >>>), and C<$? & 127> gives which signal, if any, the process died
46514521from, and C<$? & 128> reports whether there was a core dump.
46524522
46534523=end original
46544524
46554525最後に close したパイプ、バッククォート (C<``>) コマンド、
46564526成功した C<wait()> または waitpid() 呼び出し、C<system()> 演算子が返した
46574527ステータス。
46584528このステータスワードは伝統的な Unix の C<wait()> システムコールが返した
4659452916 ビットのステータス(またはそのように見えるもの)です。
46604530従ってサブプロセスの exit 値は、実際には (C<<< $? >> 8 >>>)
46614531で、C<$? & 127> は、もしあれば、そのプロセスを止めたシグナルで、
46624532C<$? & 128> はコアダンプがあるかどうかを示します。
46634533
46644534=begin original
46654535
46664536Additionally, if the C<h_errno> variable is supported in C, its value
46674537is returned via C<$?> if any C<gethost*()> function fails.
46684538
46694539=end original
46704540
46714541さらに、C で C<h_errno> 変数に対応している場合は、
46724542C<gethost*()> が失敗したときに C<$?> を通して返されます。
46734543
46744544=begin original
46754545
46764546If you have installed a signal handler for C<SIGCHLD>, the
46774547value of C<$?> will usually be wrong outside that handler.
46784548
46794549=end original
46804550
46814551C<SIGCHLD> のシグナルハンドラを設定した場合、
46824552C<$?> の値は通常ハンドラの外側では正しくない値となります。
46834553
46844554=begin original
46854555
46864556Inside an C<END> subroutine C<$?> contains the value that is going to be
46874557given to C<exit()>. You can modify C<$?> in an C<END> subroutine to
46884558change the exit status of your program. For example:
46894559
46904560=end original
46914561
46924562C<END> サブルーチンの内側では C<$?> には C<exit()> に渡されようとしている
46934563値を含みます。
46944564プログラムの終了ステータスを変更するために、C<END> サブルーチン 内で
46954565C<$?> を変更できます。
46964566例えば:
46974567
46984568=begin original
46994569
47004570 END {
47014571 $? = 1 if $? == 255; # die would make it 255
47024572 }
47034573
47044574=end original
47054575
47064576 END {
47074577 $? = 1 if $? == 255; # die は 255
47084578 }
47094579
47104580=begin original
47114581
47124582Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect the
47134583actual VMS exit status, instead of the default emulation of POSIX
47144584status; see L<perlvms/$?> for details.
47154585
47164586=end original
47174587
47184588VMS では、C<use vmsish 'status'> を指定すると、
47194589C<$?> はPOSIX ステータスをエミュレートしたものではなく、
47204590実際の VMS 終了ステータスを反映します; 詳細は L<perlvms/$?> を
47214591参照してください。
47224592
47234593=begin original
47244594
47254595Mnemonic: similar to B<sh> and B<ksh>.
47264596
47274597=end original
47284598
47294599記憶法: B<sh> や B<ksh> と同様。
47304600
47314601=item $EVAL_ERROR
47324602
47334603=item $@
47344604X<$@> X<$EVAL_ERROR>
47354605
47364606=begin original
47374607
47384608The Perl error from the last C<eval> operator, i.e. the last exception that
47394609was caught. For C<eval BLOCK>, this is either a runtime error message or the
47404610string or reference C<die> was called with. The C<eval STRING> form also
47414611catches syntax errors and other compile time exceptions.
47424612
47434613=end original
47444614
47454615最後の C<eval> 操作子による Perl のエラーです; つまり、最後に補足された
47464616例外です。
47474617C<eval BLOCK> の場合は、これは実行時エラーか、C<die> が呼び出されたときの
47484618文字列かリファレンスです。
47494619C<eval STRING> 型式は、文法エラーやその他のコンパイル時例外も捕捉します。
47504620
47514621=begin original
47524622
47534623If no error occurs, C<eval> sets C<$@> to the empty string.
47544624
47554625=end original
47564626
47574627エラーが起きなければ、C<eval> は C<$@> に空文字列を設定します。
47584628
47594629=begin original
47604630
47614631Warning messages are not collected in this variable. You can, however,
47624632set up a routine to process warnings by setting C<$SIG{__WARN__}> as
47634633described in L</%SIG>.
47644634
47654635=end original
47664636
47674637警告メッセージはこの変数に入りません。
47684638しかし、L</%SIG> に記述されている C<$SIG{__WARN__}> にセットすることで
47694639警告を処理するルーチンを設定できます。
47704640
47714641=begin original
47724642
47734643Mnemonic: Where was the error "at"?
47744644
47754645=end original
47764646
47774647記憶法: どこで ("at") エラーが起ったか。
47784648
47794649=back
47804650
47814651=head2 Variables related to the interpreter state
47824652
47834653(インタプリタの状態に関連する変数)
47844654
47854655=begin original
47864656
47874657These variables provide information about the current interpreter state.
47884658
47894659=end original
47904660
47914661これらの変数は現在のインタプリタの状態に関する情報を提供します。
47924662
47934663=over 8
47944664
47954665=item $COMPILING
47964666
47974667=item $^C
47984668X<$^C> X<$COMPILING>
47994669
48004670=begin original
48014671
48024672The current value of the flag associated with the B<-c> switch.
48034673Mainly of use with B<-MO=...> to allow code to alter its behavior
48044674when being compiled, such as for example to C<AUTOLOAD> at compile
48054675time rather than normal, deferred loading. Setting
48064676C<$^C = 1> is similar to calling C<B::minus_c>.
48074677
48084678=end original
48094679
48104680B<-c> スイッチに関連付けられた現在の値です。
48114681主に B<-MO=...> と共に用いられ、例えば C<AUTOLOAD> を通常の遅延ロードでは
48124682なくコンパイル時に実行するといった、コンパイル時の振る舞いを
48134683変えるために用います。
48144684C<$^C = 1> に設定することは C<B::minus_c> を呼び出すのと似ています。
48154685
48164686=begin original
48174687
48184688This variable was added in Perl v5.6.0.
48194689
48204690=end original
48214691
48224692この変数は Perl v5.6.0 で追加されました。
48234693
48244694=item $DEBUGGING
48254695
48264696=item $^D
48274697X<$^D> X<$DEBUGGING>
48284698
48294699=begin original
48304700
48314701The current value of the debugging flags. May be read or set. Like its
48324702L<command-line equivalent|perlrun/B<-D>I<letters>>, you can use numeric
48334703or symbolic values, e.g. C<$^D = 10> or C<$^D = "st">. See
48344704L<perlrun/B<-D>I<number>>. The contents of this variable also affects the
48354705debugger operation. See L<perldebguts/Debugger Internals>.
48364706
48374707=end original
48384708
48394709デバッグフラグの現在の値を示します。
48404710読み書き可能です。
48414711L<コマンドラインによる等価な機能|perlrun/B<-D>I<letters>> と同様に、
48424712数値とシンボル値が使えます
48434713(例: C<$^D = 10> または C<$^D = "st">)。
48444714L<perlrun/B<-D>I<number>> を参照してください。
48454715この変数の内容はデバッガ操作にも影響されます。
48464716L<perldebguts/Debugger Internals> を参照してください。
48474717
48484718=begin original
48494719
48504720Mnemonic: value of B<-D> switch.
48514721
48524722=end original
48534723
48544724記憶法: B<-D> スイッチの値。
48554725
48564726=item ${^ENCODING}
48574727X<${^ENCODING}>
48584728
48594729=begin original
48604730
48614731This variable is no longer supported.
48624732
48634733=end original
48644734
48654735この変数はもはや対応していません。
48664736
48674737=begin original
48684738
48694739It used to hold the I<object reference> to the C<Encode> object that was
48704740used to convert the source code to Unicode.
48714741
48724742=end original
48734743
48744744これはソースコードを Unicode に変換するために使われる
48754745C<Encode> オブジェクトへの I<オブジェクトリファレンス> を保持していました。
48764746
48774747=begin original
48784748
48794749Its purpose was to allow your non-ASCII Perl
48804750scripts not to have to be written in UTF-8; this was
48814751useful before editors that worked on UTF-8 encoded text were common, but
48824752that was long ago. It caused problems, such as affecting the operation
48834753of other modules that weren't expecting it, causing general mayhem.
48844754
48854755=end original
48864756
48874757この目的は、非 ASCII Perl スクリプトを UTF-8 で書く必要をなくすためでした;
48884758これは UTF-8 エンコードされたテキストで動作するエディタが一般的になる前は
48894759有用でしたが、それはずっと前です。
48904760これは、想定してない他のモジュールの操作に影響を与えるような問題を引き起こし、
48914761一般的には破壊的です。
48924762
48934763=begin original
48944764
48954765If you need something like this functionality, it is recommended that use
48964766you a simple source filter, such as L<Filter::Encoding>.
48974767
48984768=end original
48994769
49004770この機能のような何かが必要な場合は、L<Filter::Encoding> のような
49014771単純なソースフィルタを使うことを勧めます。
49024772
49034773=begin original
49044774
49054775If you are coming here because code of yours is being adversely affected
49064776by someone's use of this variable, you can usually work around it by
49074777doing this:
49084778
49094779=end original
49104780
49114781あなたがここに来た理由が、誰かがこの変数を使うことであなたのコードが
49124782意図せずに影響を受けたためなら、通常は次のようにして回避できます:
49134783
49144784 local ${^ENCODING};
49154785
49164786=begin original
49174787
49184788near the beginning of the functions that are getting broken. This
49194789undefines the variable during the scope of execution of the including
49204790function.
49214791
49224792=end original
49234793
49244794これを壊れてしまった関数の先頭付近に書きます。
49254795これにより、この関数を含むスコープを実行する間この変数を未定義にします。
49264796
49274797=begin original
49284798
49294799This variable was added in Perl 5.8.2 and removed in 5.26.0.
49304800Setting it to anything other than C<undef> was made fatal in Perl 5.28.0.
49314801
49324802=end original
49334803
49344804この変数は Perl 5.8.2 で追加され、5.26.0 で削除されました。
49354805Perl 5.28.0 から、これに C<undef> 以外の値を設定すると致命的エラーになります。
49364806
49374807=item ${^GLOBAL_PHASE}
49384808X<${^GLOBAL_PHASE}>
49394809
49404810=begin original
49414811
49424812The current phase of the perl interpreter.
49434813
49444814=end original
49454815
49464816perl インタプリタの現在のフェーズ。
49474817
49484818=begin original
49494819
49504820Possible values are:
49514821
49524822=end original
49534823
49544824取り得る値は:
49554825
49564826=over 8
49574827
49584828=item CONSTRUCT
49594829
49604830=begin original
49614831
49624832The C<PerlInterpreter*> is being constructed via C<perl_construct>. This
49634833value is mostly there for completeness and for use via the
49644834underlying C variable C<PL_phase>. It's not really possible for Perl
49654835code to be executed unless construction of the interpreter is
49664836finished.
49674837
49684838=end original
49694839
49704840C<PerlInterpreter*> は C<perl_construct> で構築されます。
49714841この変数はほとんど完全性のためと、基礎となっている C 変数
49724842C<PL_phase> 経由での使用のために存在しています。
49734843実際にはインタプリタの構築が完了しない限り Perl コードを
49744844実行することはできません。
49754845
49764846=item START
49774847
49784848=begin original
49794849
49804850This is the global compile-time. That includes, basically, every
49814851C<BEGIN> block executed directly or indirectly from during the
49824852compile-time of the top-level program.
49834853
49844854=end original
49854855
49864856これはコンパイル時にグローバルです。
49874857これは基本的に、直接実行されたり、トップレベルプログラムの
49884858コンパイル時の間に間接的に実行される全ての C<BEGIN> です。
49894859
49904860=begin original
49914861
49924862This phase is not called "BEGIN" to avoid confusion with
49934863C<BEGIN>-blocks, as those are executed during compile-time of any
49944864compilation unit, not just the top-level program. A new, localised
49954865compile-time entered at run-time, for example by constructs as
49964866C<eval "use SomeModule"> are not global interpreter phases, and
49974867therefore aren't reflected by C<${^GLOBAL_PHASE}>.
49984868
49994869=end original
50004870
50014871C<BEGIN> ブロックとの混乱を避けるために、このフェーズの名前は "BEGIN" では
50024872ありません; これらは単にトップレベルプログラムではなく、任意のコンパイル
50034873ユニットのコンパイル中に実行されます。
50044874例えば C<eval "use SomeModule"> のように、実行時に入った
50054875新しいローカル化されたコンパイル時はグローバルなインタプリタフェーズではなく、
50064876従って C<${^GLOBAL_PHASE}> に反映されません。
50074877
50084878=item CHECK
50094879
50104880=begin original
50114881
50124882Execution of any C<CHECK> blocks.
50134883
50144884=end original
50154885
50164886C<CHECK> ブロックの実行。
50174887
50184888=item INIT
50194889
50204890=begin original
50214891
50224892Similar to "CHECK", but for C<INIT>-blocks, not C<CHECK> blocks.
50234893
50244894=end original
50254895
50264896"CHECK" と似ていますが、C<CHECK> ブロックではなく C<INIT> ブロック。
50274897
50284898=item RUN
50294899
50304900=begin original
50314901
50324902The main run-time, i.e. the execution of C<PL_main_root>.
50334903
50344904=end original
50354905
50364906メインの実行; つまり C<PL_main_root> の実行。
50374907
50384908=item END
50394909
50404910=begin original
50414911
50424912Execution of any C<END> blocks.
50434913
50444914=end original
50454915
50464916C<END> ブロックの実行。
50474917
50484918=item DESTRUCT
50494919
50504920=begin original
50514921
50524922Global destruction.
50534923
50544924=end original
50554925
50564926グローバルなデストラクタ。
50574927
50584928=back
50594929
50604930=begin original
50614931
50624932Also note that there's no value for UNITCHECK-blocks. That's because
50634933those are run for each compilation unit individually, and therefore is
50644934not a global interpreter phase.
50654935
50664936=end original
50674937
50684938また、UNITCHECK ブロックのための値はないことに注意してください。
50694939なぜなら、これらはコンパイルユニット毎に独立に実行され、従って
50704940グローバルなインタプリタフェーズではないからです。
50714941
50724942=begin original
50734943
50744944Not every program has to go through each of the possible phases, but
50754945transition from one phase to another can only happen in the order
50764946described in the above list.
50774947
50784948=end original
50794949
50804950全てのプログラムが可能な全てのフェーズを通らなければならないわけでは
50814951ありませんが、あるフェーズから他のフェーズへの移行は上述の
50824952順でのみ起こります。
50834953
50844954=begin original
50854955
50864956An example of all of the phases Perl code can see:
50874957
50884958=end original
50894959
50904960Perl コードの全てのフェーズを見る例です:
50914961
50924962 BEGIN { print "compile-time: ${^GLOBAL_PHASE}\n" }
50934963
50944964 INIT { print "init-time: ${^GLOBAL_PHASE}\n" }
50954965
50964966 CHECK { print "check-time: ${^GLOBAL_PHASE}\n" }
50974967
50984968 {
50994969 package Print::Phase;
51004970
51014971 sub new {
51024972 my ($class, $time) = @_;
51034973 return bless \$time, $class;
51044974 }
51054975
51064976 sub DESTROY {
51074977 my $self = shift;
51084978 print "$$self: ${^GLOBAL_PHASE}\n";
51094979 }
51104980 }
51114981
51124982 print "run-time: ${^GLOBAL_PHASE}\n";
51134983
51144984 my $runtime = Print::Phase->new(
51154985 "lexical variables are garbage collected before END"
51164986 );
51174987
51184988 END { print "end-time: ${^GLOBAL_PHASE}\n" }
51194989
51204990 our $destruct = Print::Phase->new(
51214991 "package variables are garbage collected after END"
51224992 );
51234993
51244994=begin original
51254995
51264996This will print out
51274997
51284998=end original
51294999
51305000これは以下のものを出力します:
51315001
51325002 compile-time: START
51335003 check-time: CHECK
51345004 init-time: INIT
51355005 run-time: RUN
51365006 lexical variables are garbage collected before END: RUN
51375007 end-time: END
51385008 package variables are garbage collected after END: DESTRUCT
51395009
51405010=begin original
51415011
51425012This variable was added in Perl 5.14.0.
51435013
51445014=end original
51455015
51465016この変数は Perl 5.14.0 で追加されました。
51475017
51485018=item $^H
51495019X<$^H>
51505020
51515021=begin original
51525022
51535023WARNING: This variable is strictly for
51545024internal use only. Its availability,
51555025behavior, and contents are subject to change without notice.
51565026
51575027=end original
51585028
51595029警告: この変数は厳密に内部使用に限定されます。
51605030その可用性、挙動、内容は告知なく変更される可能性があります。
51615031
51625032=begin original
51635033
51645034This variable contains compile-time hints for the Perl interpreter. At the
51655035end of compilation of a BLOCK the value of this variable is restored to the
51665036value when the interpreter started to compile the BLOCK.
51675037
51685038=end original
51695039
51705040この変数には Perl インタプリタのコンパイル時のヒントが入ります。
51715041BLOCK のコンパイル終了時に、この変数の値は
51725042インタプリタが BLOCK のコンパイルを開始した時の値に戻されます。
51735043
51745044=begin original
51755045
51765046When perl begins to parse any block construct that provides a lexical scope
51775047(e.g., eval body, required file, subroutine body, loop body, or conditional
51785048block), the existing value of C<$^H> is saved, but its value is left unchanged.
51795049When the compilation of the block is completed, it regains the saved value.
51805050Between the points where its value is saved and restored, code that
51815051executes within BEGIN blocks is free to change the value of C<$^H>.
51825052
51835053=end original
51845054
51855055Perl がレキシカルスコープを持つブロック構造(eval の中身、required された
51865056ファイル、サブルーチンの中身、loop の中身、条件付きブロック)の
51875057パースを開始するとき、現在の C<$^H> の値は保存されますが、値は
51885058変更されません。
51895059ブロックのコンパイルが終わると、保存された値が戻されます。
51905060値の保存と回復の間の地点で、BEGIN ブロックの中で実行されるコードは自由に
51915061C<$^H> の値を変更できます。
51925062
51935063=begin original
51945064
51955065This behavior provides the semantic of lexical scoping, and is used in,
51965066for instance, the C<use strict> pragma.
51975067
51985068=end original
51995069
52005070この振る舞いはレキシカルスコープを持ち、その中で使えます; 例としては
52015071C<use strict> があります。
52025072
52035073=begin original
52045074
52055075The contents should be an integer; different bits of it are used for
52065076different pragmatic flags. Here's an example:
52075077
52085078=end original
52095079
52105080内容は整数であるべきです; ビット毎に異なるプラグマフラグとして使われます。
52115081以下は例です:
52125082
52135083 sub add_100 { $^H |= 0x100 }
52145084
52155085 sub foo {
52165086 BEGIN { add_100() }
52175087 bar->baz($boon);
52185088 }
52195089
52205090=begin original
52215091
52225092Consider what happens during execution of the BEGIN block. At this point
52235093the BEGIN block has already been compiled, but the body of C<foo()> is still
52245094being compiled. The new value of C<$^H>
52255095will therefore be visible only while
52265096the body of C<foo()> is being compiled.
52275097
52285098=end original
52295099
52305100BEGIN ブロックの実行中に起こることを考えてみます。
52315101この時点で BEGIN ブロックは既にコンパイルされていますが、
52325102C<foo()> の中身はまだコンパイル中です。
52335103従って C<$^H> の新しい値は C<foo()> の中身がコンパイル中にのみ
52345104見ることが出来ます。
52355105
52365106=begin original
52375107
52385108Substitution of C<BEGIN { add_100() }> block with:
52395109
52405110=end original
52415111
52425112C<BEGIN { add_100() }> ブロックを以下のように変更すると:
52435113
52445114 BEGIN { require strict; strict->import('vars') }
52455115
52465116=begin original
52475117
52485118demonstrates how C<use strict 'vars'> is implemented. Here's a conditional
52495119version of the same lexical pragma:
52505120
52515121=end original
52525122
52535123どのように C<use strict 'vars'> が実装されているかがわかります。
52545124以下は同じレキシカルプラグマの条件付き版です:
52555125
52565126 BEGIN {
52575127 require strict; strict->import('vars') if $condition
52585128 }
52595129
52605130=begin original
52615131
52625132This variable was added in Perl 5.003.
52635133
52645134=end original
52655135
52665136この変数は Perl 5.003 で追加されました。
52675137
52685138=item %^H
52695139X<%^H>
52705140
52715141=begin original
52725142
52735143The C<%^H> hash provides the same scoping semantic as C<$^H>. This makes
52745144it useful for implementation of lexically scoped pragmas. See
52755145L<perlpragma>. All the entries are stringified when accessed at
52765146runtime, so only simple values can be accommodated. This means no
52775147pointers to objects, for example.
52785148
52795149=end original
52805150
52815151C<%^H> ハッシュは C<$^H> と同じスコープを持ちます。
52825152これはレキシカルスコープを持つプラグマを実装するのに便利です。
52835153L<perlpragma> を参照してください。
52845154実行時にアクセスされると全てのエントリは文字列化されるので、
52855155単純な値のみに対応します。
52865156これは、例えばオブジェクトへのポインタはないということです。
52875157
52885158=begin original
52895159
52905160When putting items into C<%^H>, in order to avoid conflicting with other
52915161users of the hash there is a convention regarding which keys to use.
52925162A module should use only keys that begin with the module's name (the
52935163name of its main package) and a "/" character. For example, a module
52945164C<Foo::Bar> should use keys such as C<Foo::Bar/baz>.
52955165
52965166=end original
52975167
52985168C<%^H> に追加するとき、他のハッシュのユーザーとの衝突を回避するために、
52995169キーの使い方に関する慣習があります。
53005170モジュールはモジュールの名前(主なパッケージの名前)と "/" 文字で始まる
53015171キーのみを使うべきです。
53025172例えば、モジュール C<Foo::Bar> は C<Foo::Bar/baz> のようなキーを
53035173使うべきです。
53045174
53055175=begin original
53065176
53075177This variable was added in Perl v5.6.0.
53085178
53095179=end original
53105180
53115181この変数は Perl v5.6.0 で追加されました。
53125182
53135183=item ${^OPEN}
53145184X<${^OPEN}>
53155185
53165186=begin original
53175187
53185188An internal variable used by PerlIO. A string in two parts, separated
53195189by a C<\0> byte, the first part describes the input layers, the second
53205190part describes the output layers.
53215191
53225192=end original
53235193
53245194PerlIO で使われる内部変数です。
53255195文字列は C<\0> で分割された二つの部分からなり、前半は入力層を、
53265196後半は出力層を示します。
53275197
53285198=begin original
53295199
53305200This variable was added in Perl v5.8.0.
53315201
53325202=end original
53335203
53345204この変数は Perl v5.8.0 で追加されました。
53355205
53365206=item $PERLDB
53375207
53385208=item $^P
53395209X<$^P> X<$PERLDB>
53405210
53415211=begin original
53425212
53435213The internal variable for debugging support. The meanings of the
53445214various bits are subject to change, but currently indicate:
53455215
53465216=end original
53475217
53485218デバッグ機能のための内部変数です。
53495219それぞれのビットの意味は変わるかもしれませんが、
53505220現在のところは以下の通りです:
53515221
53525222=over 6
53535223
53545224=item 0x01
53555225
53565226=begin original
53575227
53585228Debug subroutine enter/exit.
53595229
53605230=end original
53615231
53625232サブルーチンの出入りをデバッグします。
53635233
53645234=item 0x02
53655235
53665236=begin original
53675237
53685238Line-by-line debugging. Causes C<DB::DB()> subroutine to be called for
53695239each statement executed. Also causes saving source code lines (like
537052400x400).
53715241
53725242=end original
53735243
53745244行毎にデバッグします。
53755245各行を実行する毎に C<DB::DB()> サブルーチンを呼び出します。
53765246さらに、(0x400 のように) ソースコードを保存します。
53775247
53785248=item 0x04
53795249
53805250=begin original
53815251
53825252Switch off optimizations.
53835253
53845254=end original
53855255
53865256最適化を行いません。
53875257
53885258=item 0x08
53895259
53905260=begin original
53915261
53925262Preserve more data for future interactive inspections.
53935263
53945264=end original
53955265
53965266将来の対話的な検査のためにより多くのデータを保存します。
53975267
53985268=item 0x10
53995269
54005270=begin original
54015271
54025272Keep info about source lines on which a subroutine is defined.
54035273
54045274=end original
54055275
54065276サブルーチンが定義されたソース行に関する情報を保持します。
54075277
54085278=item 0x20
54095279
54105280=begin original
54115281
54125282Start with single-step on.
54135283
54145284=end original
54155285
54165286シングルステップ実行で開始します。
54175287
54185288=item 0x40
54195289
54205290=begin original
54215291
54225292Use subroutine address instead of name when reporting.
54235293
54245294=end original
54255295
54265296報告時にサブルーチン名でなくサブルーチンのアドレスを使います。
54275297
54285298=item 0x80
54295299
54305300=begin original
54315301
54325302Report C<goto &subroutine> as well.
54335303
54345304=end original
54355305
54365306C<goto &subroutine> も同様に報告します。
54375307
54385308=item 0x100
54395309
54405310=begin original
54415311
54425312Provide informative "file" names for evals based on the place they were compiled.
54435313
54445314=end original
54455315
54465316eval に対して、コンパイルされた位置を元にした「ファイル」名を提供します。
54475317
54485318=item 0x200
54495319
54505320=begin original
54515321
54525322Provide informative names to anonymous subroutines based on the place they
54535323were compiled.
54545324
54555325=end original
54565326
54575327無名サブルーチンに対して、
54585328コンパイルされた位置を基にした参考名を提供します。
54595329
54605330=item 0x400
54615331
54625332=begin original
54635333
54645334Save source code lines into C<@{"_<$filename"}>.
54655335
54665336=end original
54675337
54685338ソースコードの行数を C<@{"_<$filename"}> に保存します。
54695339
54705340=item 0x800
54715341
54725342=begin original
54735343
54745344When saving source, include evals that generate no subroutines.
54755345
54765346=end original
54775347
54785348ソースを保存するときに、サブルーチンがない eval を含みます。
54795349
54805350=item 0x1000
54815351
54825352=begin original
54835353
54845354When saving source, include source that did not compile.
54855355
54865356=end original
54875357
54885358ソースを保存するときに、コンパイルしていないソースを含みます。
54895359
54905360=back
54915361
54925362=begin original
54935363
54945364Some bits may be relevant at compile-time only, some at
54955365run-time only. This is a new mechanism and the details may change.
54965366See also L<perldebguts>.
54975367
54985368=end original
54995369
55005370一部のビットはコンパイル時にのみまたは実行時にのみ意味があります。
55015371これは新しい機構であり、詳細は変更されるかもしれません。
55025372L<perldebguts> も参照してください。
55035373
55045374=item ${^TAINT}
55055375X<${^TAINT}>
55065376
55075377=begin original
55085378
55095379Reflects if taint mode is on or off. 1 for on (the program was run with
55105380B<-T>), 0 for off, -1 when only taint warnings are enabled (i.e. with
55115381B<-t> or B<-TU>).
55125382
55135383=end original
55145384
55155385汚染検査モードのオン・オフを反映します。
551653861 はオン(プログラムは B<-T> 付きで実行されている)、0 はオフ、-1 は汚染
55175387警告のみが有効になっている(つまり B<-t> か B<-TU>)ことを意味します。
55185388
55195389=begin original
55205390
55215391This variable is read-only.
55225392
55235393=end original
55245394
55255395この変数は読み込み専用です。
55265396
55275397=begin original
55285398
55295399This variable was added in Perl v5.8.0.
55305400
55315401=end original
55325402
55335403この変数は Perl v5.8.0 で追加されました。
55345404
55355405=item ${^SAFE_LOCALES}
55365406X<${^SAFE_LOCALES}>
55375407
55385408=begin original
55395409
55405410Reflects if safe locale operations are available to this perl (when the
55415411value is 1) or not (the value is 0). This variable is always 1 if the
55425412perl has been compiled without threads. It is also 1 if this perl is
55435413using thread-safe locale operations. Note that an individual thread may
55445414choose to use the global locale (generally unsafe) by calling
55455415L<perlapi/switch_to_global_locale>. This variable currently is still
55465416set to 1 in such threads.
55475417
55485418=end original
55495419
55505420この perl で安全なロケール操作が利用可能 (値が 1 の場合) かそうでない
55515421(値が 0 の場合) かを反映します。
55525422この変数は、perl がスレッドなしでコンパイルされている場合は常に 1 です。
55535423また、perl がスレッドセーフなロケール操作を使っている場合は 1 です。
55545424個々のスレッドは L<perlapi/switch_to_global_locale> を呼び出すことで
55555425(一般的にはスレッドセーフでない) グローバルなロケールを使うことを
55565426選ぶかも知れないことに注意してください。
55575427この変数はそのようなスレッドでも 1 のままです。
55585428
55595429=begin original
55605430
55615431This variable is read-only.
55625432
55635433=end original
55645434
55655435この変数は読み込み専用です。
55665436
55675437=begin original
55685438
55695439This variable was added in Perl v5.28.0.
55705440
55715441=end original
55725442
55735443この変数は Perl v5.28.0 で追加されました。
55745444
55755445=item ${^UNICODE}
55765446X<${^UNICODE}>
55775447
55785448=begin original
55795449
55805450Reflects certain Unicode settings of Perl. See L<perlrun>
55815451documentation for the C<-C> switch for more information about
55825452the possible values.
55835453
55845454=end original
55855455
55865456Perl のいくつかの Unicode 設定を反映します。
55875457設定できる値に関するさらなる情報については L<perlrun> の C<-C> オプションを
55885458参照してください。
55895459
55905460=begin original
55915461
55925462This variable is set during Perl startup and is thereafter read-only.
55935463
55945464=end original
55955465
55965466この変数は Perl 起動時に設定され、その後は読み込み専用です。
55975467
55985468=begin original
55995469
56005470This variable was added in Perl v5.8.2.
56015471
56025472=end original
56035473
56045474この変数は Perl v5.8.2 で追加されました。
56055475
56065476=item ${^UTF8CACHE}
56075477X<${^UTF8CACHE}>
56085478
56095479=begin original
56105480
56115481This variable controls the state of the internal UTF-8 offset caching code.
561254821 for on (the default), 0 for off, -1 to debug the caching code by checking
56135483all its results against linear scans, and panicking on any discrepancy.
56145484
56155485=end original
56165486
56175487この変数は内部 UTF-8 オフセットキャッシュコードの状態を制御します。
561854881 はオン(デフォルト)、0 はオフ、-1 は全ての結果を線形走査と比較して、
56195489矛盾があれば異常終了する、という形でキャッシュコードをデバッグします。
56205490
56215491=begin original
56225492
56235493This variable was added in Perl v5.8.9. It is subject to change or
56245494removal without notice, but is currently used to avoid recalculating the
56255495boundaries of multi-byte UTF-8-encoded characters.
56265496
56275497=end original
56285498
56295499この変数は Perl v5.8.9 で追加されました。
56305500これは予告なく変更されたり削除されたりするかもしれませんが、現在のところ
56315501複数バイト UTF-8 エンコード文字の境界の再計算を避けるために使われます。
56325502
56335503=item ${^UTF8LOCALE}
56345504X<${^UTF8LOCALE}>
56355505
56365506=begin original
56375507
56385508This variable indicates whether a UTF-8 locale was detected by perl at
56395509startup. This information is used by perl when it's in
56405510adjust-utf8ness-to-locale mode (as when run with the C<-CL> command-line
56415511switch); see L<perlrun> for more info on this.
56425512
56435513=end original
56445514
56455515この変数は、起動時に perl によって UTF-8 ロケールが検出されたかどうかを
56465516示します。
56475517この情報は(C<-CL> コマンドラインスイッチで起動されることによって)
56485518「utf8 性をロケールに合わせる」モードのときに perl によって使われます;
56495519これに関するさらなる情報は L<perlrun> を参照してください。
56505520
56515521=begin original
56525522
56535523This variable was added in Perl v5.8.8.
56545524
56555525=end original
56565526
56575527この変数は Perl v5.8.8 で追加されました。
56585528
56595529=back
56605530
56615531=head2 Deprecated and removed variables
56625532
56635533(非推奨および削除された変数)
56645534
56655535=begin original
56665536
56675537Deprecating a variable announces the intent of the perl maintainers to
56685538eventually remove the variable from the language. It may still be
56695539available despite its status. Using a deprecated variable triggers
56705540a warning.
56715541
56725542=end original
56735543
56745544非推奨となった変数は、perl のメンテナが最終的にこの変数を
56755545削除するということを意図して通知されます。
56765546その状態にも関わらず、まだ利用可能です。
56775547非推奨となった変数を使うと警告が出ます。
56785548
56795549=begin original
56805550
56815551Once a variable is removed, its use triggers an error telling you
56825552the variable is unsupported.
56835553
56845554=end original
56855555
56865556変数が削除された後で変数を使うと、この変数が非対応となったことを
56875557知らせるエラーが出ます。
56885558
56895559=begin original
56905560
56915561See L<perldiag> for details about error messages.
56925562
56935563=end original
56945564
56955565エラーメッセージの詳細については L<perldiag> を参照してください。
56965566
56975567=over 8
56985568
56995569=item $#
57005570X<$#>
57015571
57025572=begin original
57035573
57045574C<$#> was a variable that could be used to format printed numbers.
57055575After a deprecation cycle, its magic was removed in Perl v5.10.0 and
57065576using it now triggers a warning: C<$# is no longer supported>.
57075577
57085578=end original
57095579
57105580C<$#> は、表示番号をフォーマットするために使われていました。
57115581非推奨化の後、このマジックは Perl v5.10.0 で取り除かれ、警告を
57125582引き起こします: C<$# is no longer supported>.
57135583
57145584=begin original
57155585
57165586This is not the sigil you use in front of an array name to get the
57175587last index, like C<$#array>. That's still how you get the last index
57185588of an array in Perl. The two have nothing to do with each other.
57195589
57205590=end original
57215591
57225592これは C<$#array> のように最後のインデックスを得るために配列名の前に付ける
57235593印ではありません。
57245594これは今でも Perl で配列の最後のインデックスを得る方法です。
57255595これら二つには互いに何の関係もありません。
57265596
57275597=begin original
57285598
57295599Deprecated in Perl 5.
57305600
57315601=end original
57325602
57335603Perl 5 で非推奨となりました。
57345604
57355605=begin original
57365606
57375607Removed in Perl v5.10.0.
57385608
57395609=end original
57405610
57415611Perl v5.10.0 で削除されました。
57425612
57435613=item $*
57445614X<$*>
57455615
57465616=begin original
57475617
57485618C<$*> was a variable that you could use to enable multiline matching.
57495619After a deprecation cycle, its magic was removed in Perl v5.10.0.
57505620Using it now triggers a warning: C<$* is no longer supported>.
57515621You should use the C</s> and C</m> regexp modifiers instead.
57525622
57535623=end original
57545624
57555625C<$*> は複数行マッチングを有効にするために使われていた変数です。
57565626非推奨化の後、このマジックは Perl v5.10.0 で削除されました。
57575627これを使うと警告を引き起こします: C<$* is no longer supported>。
57585628代わりに C</s> と C</m> の正規表現修飾子を使うべきです。
57595629
57605630=begin original
57615631
57625632Deprecated in Perl 5.
57635633
57645634=end original
57655635
57665636Perl 5 で非推奨となりました。
57675637
57685638=begin original
57695639
57705640Removed in Perl v5.10.0.
57715641
57725642=end original
57735643
57745644Perl v5.10.0 で削除されました。
57755645
57765646=item $[
57775647X<$[>
57785648
57795649=begin original
57805650
57815651This variable stores the index of the first element in an array, and
57825652of the first character in a substring. The default is 0, but you could
57835653theoretically set it to 1 to make Perl behave more like B<awk> (or Fortran)
57845654when subscripting and when evaluating the index() and substr() functions.
57855655
57865656=end original
57875657
57885658この変数は配列の最初の要素や、文字列の最初の文字のインデックスを
57895659保管します。
57905660デフォルトは 0 ですが、理論的には、index() 関数や
57915661substr() 関数を評価するときに、Perl の動作をより B<awk>
57925662(や Fortran) に近づけるため、1 に設定することもできます。
57935663
57945664=begin original
57955665
57965666As of release 5 of Perl, assignment to C<$[> is treated as a compiler
57975667directive, and cannot influence the behavior of any other file.
57985668(That's why you can only assign compile-time constants to it.)
57995669Its use is highly discouraged.
58005670
58015671=end original
58025672
58035673Perl 5 からは C<$[> への代入は、コンパイラ指示子として扱われ、
58045674他のファイルの動作に影響を与えることがなくなりました。
58055675(これが、コンパイル時定数しか代入できない理由です。)
58065676この変数の使用は非推奨です。
58075677
58085678=begin original
58095679
58105680Prior to Perl v5.10.0, assignment to C<$[> could be seen from outer lexical
58115681scopes in the same file, unlike other compile-time directives (such as
58125682L<strict>). Using local() on it would bind its value strictly to a lexical
58135683block. Now it is always lexically scoped.
58145684
58155685=end original
58165686
58175687Perl v5.10.0 より前では、C<$[> は(L<strict> のような)その他のコンパイル時
58185688指示子と異なり、同じファイルのレキシカルスコープの外側から見ることが
58195689出来ていました。
58205690これに local() を使うとこの値を厳密にレキシカルスコープの内側に限定します。
58215691今では常にレキシカルスコープを持ちます。
58225692
58235693=begin original
58245694
5825As of Perl v5.16.0, it is implemented by the L<arybase> module.
5695As of Perl v5.16.0, it is implemented by the L<arybase> module. See
5696L<arybase> for more details on its behaviour.
58265697
58275698=end original
58285699
58295700Perl v5.16.0 から、これは L<arybase> モジュールで実装されています。
5701この振る舞いに関するさらなる詳細については L<arybase> を参照してください。
58305702
58315703=begin original
58325704
5833As of Perl v5.30.0, or under C<use v5.16>, or C<no feature "array_base">,
5705Under C<use v5.16>, or C<no feature "array_base">, C<$[> no longer has any
5834C<$[> no longer has any effect, and always contains 0.
5706effect, and always contains 0. Assigning 0 to it is permitted, but any
5835Assigning 0 to it is permitted, but any other value will produce an error.
5707other value will produce an error.
58365708
58375709=end original
58385710
5839Perl v5.30.0 以降か、C<use v5.16> または C<no feature "array_base"> の基では、
5711C<use v5.16> または C<no feature "array_base"> の基では、C<$[> は
5840C<$[> はもはや何の効果もなく、常に 0 が入っています。
5712もはや何の効果もなく、常に 0 が入っています。
58415713これに 0 を代入することは許されますが、それ以外の値はエラーを引き起こします。
58425714
58435715=begin original
58445716
58455717Mnemonic: [ begins subscripts.
58465718
58475719=end original
58485720
58495721記憶法: [ は添え字付けの始め。
58505722
58515723=begin original
58525724
58535725Deprecated in Perl v5.12.0.
58545726
58555727=end original
58565728
58575729Perl v5.12.0 で非推奨となりました。
5730
5731=begin original
5732
5733Assigning a non-zero value be fatal in Perl v5.30.0.
5734
5735=end original
5736
5737Perl v5.30.0 から、0 以外の値を代入すると致命的エラーになります。
58585738
58595739=back
58605740
58615741=cut
58625742
58635743=begin meta
58645744
58655745Translate: 吉村 寿人 <JAE00534@niftyserve.or.jp> (5.000)
58665746Update: Kentaro Shirakata <argrath@ub32.org> (5.6.1-)
58675747Status: completed
58685748
58695749=end meta