perlvar > 5.10.1 との差分

perlvar 5.10.1 と 5.6.1 の差分

1
21=encoding euc-jp
32
43=head1 NAME
54
65=begin original
76
87perlvar - Perl predefined variables
98
109=end original
1110
1211perlvar - Perl で定義済みの変数
1312
1413=head1 DESCRIPTION
1514
1615=head2 Predefined Names
1716
1817(定義済みの変数)
1918
2019=begin original
2120
2221The following names have special meaning to Perl. Most
2322punctuation names have reasonable mnemonics, or analogs in the
2423shells. Nevertheless, if you wish to use long variable names,
2524you need only say
2625
2726=end original
2827
2928以下の名前は Perl では特別な意味を持ちます。
3029記号的な名前の多くは記憶法があるか、シェルでの類推が可能です。
3130それでも長い名前を使用したい場合には
3231
3332 use English;
3433
3534=begin original
3635
37at the top of your program. This aliases all the short names to the long
36at the top of your program. This will alias all the short names to the
38names in the current package. Some even have medium names, generally
37long names in the current package. Some even have medium names,
39borrowed from B<awk>. In general, it's best to use the
38generally borrowed from B<awk>.
4039
4140=end original
4241
4342とプログラムの最初に書いてください。
4443これは、すべての短い名前の別名として、
4544カレントパッケージで長い名前を付けるものです。
4645B<awk> から持ってきた中間的な名前を持っているものもあります。
47一般的に、一番良い使い方は:
4846
49 use English '-no_match_vars';
50
5147=begin original
5248
53invocation if you don't need $PREMATCH, $MATCH, or $POSTMATCH, as it avoids
49If you don't mind the performance hit, variables that depend on the
54a certain performance hit with the use of regular expressions. See
50currently selected filehandle may instead be set by calling an
55L<English>.
51appropriate object method on the IO::Handle object. (Summary lines
52below for this contain the word HANDLE.) First you must say
5653
5754=end original
5855
59と起動することで($PREMATCH, $MATCH, $POSTMATCH が不要場合)れにより
56性能を気にしないなら現在選択さているファイルハンドル
60正規表現を使うときのパフォーマンスへの打撃を避けられます。
61L<English> を参照してください。
62
63=begin original
64
65Variables that depend on the currently selected filehandle may be set by
66calling an appropriate object method on the IO::Handle object, although
67this is less efficient than using the regular built-in variables. (Summary
68lines below for this contain the word HANDLE.) First you must say
69
70=end original
71
72現在選択されているファイルハンドルに
7357依存する変数の場合には、代わりに IO::Handle オブジェクトに
74関するオブジェクトメソッドを呼び出して設定することができますが、
58関するオブジェクトメソッドを呼び出して設定することができます
75通常の組み込み変数よりは効率が落ちます。
7659(以下の要約では HANDLE という語を含んでいます。)
7760まず最初に必ず、
7861
7962 use IO::Handle;
8063
8164=begin original
8265
8366after which you may use either
8467
8568=end original
8669
8770と書き、その後で以下のように書くか、
8871
8972 method HANDLE EXPR
9073
9174=begin original
9275
9376or more safely,
9477
9578=end original
9679
9780もしくはより安全に以下のように書きます:
9881
9982 HANDLE->method(EXPR)
10083
10184=begin original
10285
10386Each method returns the old value of the IO::Handle attribute.
104The methods each take an optional EXPR, which, if supplied, specifies the
87The methods each take an optional EXPR, which if supplied specifies the
10588new value for the IO::Handle attribute in question. If not supplied,
10689most methods do nothing to the current value--except for
10790autoflush(), which will assume a 1 for you, just to be different.
91Because loading in the IO::Handle class is an expensive operation, you should
92learn how to use the regular built-in variables.
10893
10994=end original
11095
11196それぞれのメソッドは、IO::Handle 属性の昔の値を返します。
11297メソッドはそれぞれ EXPR をとることができ、指定した場合には、
11398問題の IO::Handle 属性の新しい値を指定することになります。
11499指定しない場合には、多くのメソッドでは現在の値に対して何もしませんが、
115100autoflush() では 1 を指定されたものとします。
116
117=begin original
118
119Because loading in the IO::Handle class is an expensive operation, you should
120learn how to use the regular built-in variables.
121
122=end original
123
124101IO::Handle クラスを読み込むのはコストの高い操作なので、
125102通常の組み込み変数の使い方を覚えるべきです。
126103
127104=begin original
128105
129106A few of these variables are considered "read-only". This means that if
130107you try to assign to this variable, either directly or indirectly through
131108a reference, you'll raise a run-time exception.
132109
133110=end original
134111
135112これらの変数の中には "read-only" として扱われるものもあります。
136113つまり、そういった変数に対して、直接にしろ、リファレンスを
137114介して間接にしろ、代入を行なおうとした場合には、実行時に
138115例外処理が起動されます。
139116
140117=begin original
141118
142You should be very careful when modifying the default values of most
143special variables described in this document. In most cases you want
144to localize these variables before changing them, since if you don't,
145the change may affect other modules which rely on the default values
146of the special variables that you have changed. This is one of the
147correct ways to read the whole file at once:
148
149=end original
150
151この文書に記述されているほとんどの特殊変数のデフォルト値を変更するときには
152とても慎重になるべきです。
153ほとんどの場合、これらの変数を変更する前にこれらをローカル化したいでしょう;
154さもなければ、あなたが変更した特殊変数のデフォルト値に依存している
155その他のモジュールにも影響を与えるかもしれないからです。
156これはファイル全体を一度に読み込む正しい方法の一つです:
157
158 open my $fh, "<", "foo" or die $!;
159 local $/; # enable localized slurp mode
160 my $content = <$fh>;
161 close $fh;
162
163=begin original
164
165But the following code is quite bad:
166
167=end original
168
169しかし以下のコードは完全に悪いものです:
170
171 open my $fh, "<", "foo" or die $!;
172 undef $/; # enable slurp mode
173 my $content = <$fh>;
174 close $fh;
175
176=begin original
177
178since some other module, may want to read data from some file in the
179default "line mode", so if the code we have just presented has been
180executed, the global value of C<$/> is now changed for any other code
181running inside the same Perl interpreter.
182
183=end original
184
185なぜなら、その他のモジュールでは、デフォルトの「行モード」でファイルを
186読もうとするかも知れませんが、もし単に前述のコードを実行すると、
187C<$/> のグローバルな値が、同じ Perl インタプリタ内で実行される
188その他のコードに対しても変更されるからです。
189
190=begin original
191
192Usually when a variable is localized you want to make sure that this
193change affects the shortest scope possible. So unless you are already
194inside some short C<{}> block, you should create one yourself. For
195example:
196
197=end original
198
199通常、変数をローカル化するとき、この変更ができるだけ最短のスコープに
200影響を与えることを確実にしたいでしょう。
201従って、既に小さい C<{}> ブロックの内側であるのでない限り、それを
202自身で作るべきです。
203例えば:
204
205 my $content = '';
206 open my $fh, "<", "foo" or die $!;
207 {
208 local $/;
209 $content = <$fh>;
210 }
211 close $fh;
212
213=begin original
214
215Here is an example of how your own code can go broken:
216
217=end original
218
219以下はどのように自分のコードが壊れるかの例です:
220
221 for (1..5){
222 nasty_break();
223 print "$_ ";
224 }
225 sub nasty_break {
226 $_ = 5;
227 # do something with $_
228 }
229
230=begin original
231
232You probably expect this code to print:
233
234=end original
235
236おそらくこのコードは以下のように表示されることを期待しています:
237
238 1 2 3 4 5
239
240=begin original
241
242but instead you get:
243
244=end original
245
246しかし、以下のようになります:
247
248 5 5 5 5 5
249
250=begin original
251
252Why? Because nasty_break() modifies C<$_> without localizing it
253first. The fix is to add local():
254
255=end original
256
257なぜでしょう?
258nasty_break() は C<$_> をローカル化する前に変更するからです。
259修正するには、local() を追加します:
260
261 local $_ = 5;
262
263=begin original
264
265It's easy to notice the problem in such a short example, but in more
266complicated code you are looking for trouble if you don't localize
267changes to the special variables.
268
269=end original
270
271このような短い例では問題に気付くのは簡単ですが、より複雑なコードでは、
272もし特殊変数の変更をローカル化していないと問題を探すことになります。
273
274=begin original
275
276119The following list is ordered by scalar variables first, then the
277120arrays, then the hashes.
278121
279122=end original
280123
281124以下のリストはまずスカラ変数、それから配列、ハッシュの順に
282125並んでいます。
283126
284127=over 8
285128
286129=item $ARG
287130
288131=item $_
289X<$_> X<$ARG>
290132
291133=begin original
292134
293135The default input and pattern-searching space. The following pairs are
294136equivalent:
295137
296138=end original
297139
298140デフォルトの入力とパターン検索のスペース。
299141以下の 2つは同値です:
300142
301143 while (<>) {...} # equivalent only in while!
302144 while (defined($_ = <>)) {...}
303145
304146 /^Subject:/
305147 $_ =~ /^Subject:/
306148
307149 tr/a-z/A-Z/
308150 $_ =~ tr/a-z/A-Z/
309151
310152 chomp
311153 chomp($_)
312154
313155=begin original
314156
315157Here are the places where Perl will assume $_ even if you
316158don't use it:
317159
318160=end original
319161
320Perl が(あなたが使いたくなくても) $_ を仮定する場合がいくつかあります:
162Perl が(あなたが使いたくなくても) $_ を仮定する場合がいくつかあります
321163
322164=over 3
323165
324166=item *
325167
326168=begin original
327169
328The following functions:
170Various unary functions, including functions like ord() and int(), as well
171as the all file tests (C<-f>, C<-d>) except for C<-t>, which defaults to
172STDIN.
329173
330174=end original
331175
332様々な関数:
176様々な単項関数。ord() や int()、また C<-t> 以外の全ての
177ファイルテスト (C<-f>, C<-d>)など。C<-t> のデフォルトは STDIN です。
333178
334=begin original
335
336abs, alarm, chomp, chop, chr, chroot, cos, defined, eval, exp, glob,
337hex, int, lc, lcfirst, length, log, lstat, mkdir, oct, ord, pos, print,
338quotemeta, readlink, readpipe, ref, require, reverse (in scalar context only),
339rmdir, sin, split (on its second argument), sqrt, stat, study, uc, ucfirst,
340unlink, unpack.
341
342=end original
343
344abs, alarm, chomp, chop, chr, chroot, cos, defined, eval, exp, glob,
345hex, int, lc, lcfirst, length, log, lstat, mkdir, oct, ord, pos, print,
346quotemeta, readlink, readpipe, ref, require, reverse (スカラコンテキストのみ),
347rmdir, sin, split (の 2 番目の引数), sqrt, stat, study, uc, ucfirst,
348unlink, unpack.
349
350179=item *
351180
352181=begin original
353182
354All file tests (C<-f>, C<-d>) except for C<-t>, which defaults to STDIN.
183Various list functions like print() and unlink().
355See L<perlfunc/-X>
356184
357185=end original
358186
359デフォルトが STDIN である C<-t> を除く全てファイルテスト(C<-f>, C<-d>)
187print() unlink() など様々なリスト関数
360L<perlfunc/-X> を参照してください。
361188
362189=item *
363190
364191=begin original
365192
366The pattern matching operations C<m//>, C<s///> and C<tr///> (aka C<y///>)
193The pattern matching operations C<m//>, C<s///>, and C<tr///> when used
367when used without an C<=~> operator.
194without an C<=~> operator.
368195
369196=end original
370197
371C<=~> 演算子なしで用いられたパターンマッチ演算 C<m//>, C<s///>, C<tr///>
198C<=~> 演算子なしで用いられたパターンマッチ演算 C<m//>, C<s///>, C<tr///>
372(またの名を C<y///>)。
373199
374200=item *
375201
376202=begin original
377203
378204The default iterator variable in a C<foreach> loop if no other
379205variable is supplied.
380206
381207=end original
382208
383209C<foreach> ループでの他の変数が補われなかった場合のデフォルトの
384210繰り返し変数。
385211
386212=item *
387213
388214=begin original
389215
390216The implicit iterator variable in the grep() and map() functions.
391217
392218=end original
393219
394220grep() 関数と map() 関数の暗黙の繰り返し変数。
395221
396222=item *
397223
398224=begin original
399225
400The implicit variable of given().
401
402=end original
403
404given() の暗黙の変数。
405
406=item *
407
408=begin original
409
410226The default place to put an input record when a C<< <FH> >>
411227operation's result is tested by itself as the sole criterion of a C<while>
412228test. Outside a C<while> test, this will not happen.
413229
414230=end original
415231
416232C<< <FH> >> が単独で C<while> テストでテストされた場合の
417233結果を入れるデフォルトの場所。
418234C<while> テスト以外ではこれは起こりません。
419235
420236=back
421237
422238=begin original
423239
424As C<$_> is a global variable, this may lead in some cases to unwanted
425side-effects. As of perl 5.9.1, you can now use a lexical version of
426C<$_> by declaring it in a file or in a block with C<my>. Moreover,
427declaring C<our $_> restores the global C<$_> in the current scope.
428
429=end original
430
431C<$_> はグローバル変数なので、望まないような副作用を引き起こす場合があります。
432perl 5.9.1 から、ファイルやブロックで C<my> で宣言することで、
433レキシカル版の C<$_> が使えます。
434さらに、C<our $_> という宣言は現在のスコープでグローバルな C<$_> を
435再構築します。
436
437=begin original
438
439240(Mnemonic: underline is understood in certain operations.)
440241
441242=end original
442243
443244(記憶法: 下線はある操作を覚えるためのもの。)
444245
445246=back
446247
447248=over 8
448249
449=item $a
450
451=item $b
452X<$a> X<$b>
453
454=begin original
455
456Special package variables when using sort(), see L<perlfunc/sort>.
457Because of this specialness $a and $b don't need to be declared
458(using use vars, or our()) even when using the C<strict 'vars'> pragma.
459Don't lexicalize them with C<my $a> or C<my $b> if you want to be
460able to use them in the sort() comparison block or function.
461
462=end original
463
464sort() を使うときの特殊パッケージ変数です; L<perlfunc/sort> を
465参照してください。
466この特殊性により、$a と $b は、たとえ C<strict 'vars'> を使っているときでも
467(use vars や our() を使って) 宣言する必要がありません。
468これを sort() 比較ブロックや関数で使えるようにしたい場合は、
469C<my $a> や C<my $b> としてレキシカル化しないでください。
470
471=back
472
473=over 8
474
475250=item $<I<digits>>
476X<$1> X<$2> X<$3>
477251
478252=begin original
479253
480254Contains the subpattern from the corresponding set of capturing
481255parentheses from the last pattern match, not counting patterns
482256matched in nested blocks that have been exited already. (Mnemonic:
483257like \digits.) These variables are all read-only and dynamically
484258scoped to the current BLOCK.
485259
486260=end original
487261
488262最後のパターンマッチで対応する括弧のサブパターンにマッチした
489263文字列が入っているが、既に抜けてしまったブロックでの
490264パターンマッチは勘定に入れない。
491265(記憶法: \(数字) のようなもの。)
492266これらの変数はすべて read-onlyで、現在の BLOCK に動的なスコープを持ちます。
493267
494268=item $MATCH
495269
496270=item $&
497X<$&> X<$MATCH>
498271
499272=begin original
500273
501274The string matched by the last successful pattern match (not counting
502275any matches hidden within a BLOCK or eval() enclosed by the current
503276BLOCK). (Mnemonic: like & in some editors.) This variable is read-only
504277and dynamically scoped to the current BLOCK.
505278
506279=end original
507280
508281最後に成功したパターンマッチでマッチした文字列 (現在の
509282BLOCK で囲まれた BLOCK や eval() で隠れている部分でのマッチは
510283勘定に入れない)。
511284(記憶法: あるエディタの & ようなもの。)
512285この変数は read-only で、現在の BLOCK に動的なスコープを持ちます。
513286
514287=begin original
515288
516289The use of this variable anywhere in a program imposes a considerable
517performance penalty on all regular expression matches. See L</BUGS>.
290performance penalty on all regular expression matches. See L<BUGS>.
518291
519292=end original
520293
521294この変数をプログラムのどこかで使うと、プログラム中の全ての正規表現
522295マッチングにおいてかなりの性能低下を引き起こします。
523L</BUGS> を参照して下さい。
296L<BUGS> を参照して下さい。
524297
525=begin original
526
527See L</@-> for a replacement.
528
529=end original
530
531置き換えのためには L</@-> を参照してください。
532
533=item ${^MATCH}
534X<${^MATCH}>
535
536=begin original
537
538This is similar to C<$&> (C<$MATCH>) except that it does not incur the
539performance penalty associated with that variable, and is only guaranteed
540to return a defined value when the pattern was compiled or executed with
541the C</p> modifier.
542
543=end original
544
545これは C<$&> (C<$MATCH>) と同様ですが、この変数と関連付けられた性能上の
546ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された
547場合にのみ定義された値を返すことが保証されます。
548
549298=item $PREMATCH
550299
551300=item $`
552X<$`> X<$PREMATCH>
553301
554302=begin original
555303
556304The string preceding whatever was matched by the last successful
557305pattern match (not counting any matches hidden within a BLOCK or eval
558306enclosed by the current BLOCK). (Mnemonic: C<`> often precedes a quoted
559307string.) This variable is read-only.
560308
561309=end original
562310
563311最後の成功したパターンマッチ (現在のBLOCK で囲まれた
564312BLOCK や eval() に隠れている部分でのマッチは勘定に入れない) で
565313マッチした部分の前の文字列。
566314(記憶法: C<`> は多くの場合クォートされた文字列の前にある。)
567315この変数は read-only です。
568316
569317=begin original
570318
571319The use of this variable anywhere in a program imposes a considerable
572performance penalty on all regular expression matches. See L</BUGS>.
320performance penalty on all regular expression matches. See L<BUGS>.
573321
574322=end original
575323
576324この変数をプログラムのどこかで使うと、プログラム中の全ての正規表現
577325マッチングにおいてかなりの性能低下を引き起こします。
578L</BUGS> を参照して下さい。
326L<BUGS> を参照して下さい。
579327
580=begin original
581
582See L</@-> for a replacement.
583
584=end original
585
586置き換えのためには L</@-> を参照してください。
587
588=item ${^PREMATCH}
589X<${^PREMATCH}>
590
591=begin original
592
593This is similar to C<$`> ($PREMATCH) except that it does not incur the
594performance penalty associated with that variable, and is only guaranteed
595to return a defined value when the pattern was compiled or executed with
596the C</p> modifier.
597
598=end original
599
600これは C<$`> ($PREMATCH) と同様ですが、この変数と関連付けられた性能上の
601ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された
602場合にのみ定義された値を返すことが保証されます。
603
604328=item $POSTMATCH
605329
606330=item $'
607X<$'> X<$POSTMATCH>
608331
609332=begin original
610333
611334The string following whatever was matched by the last successful
612335pattern match (not counting any matches hidden within a BLOCK or eval()
613336enclosed by the current BLOCK). (Mnemonic: C<'> often follows a quoted
614337string.) Example:
615338
616339=end original
617340
618341最後の成功したパターンマッチ (現在のBLOCK で囲まれた
619342BLOCK や eval() に隠れている部分でのマッチは勘定に入れない) で
620343マッチした部分に続く文字列。
621344(記憶法: C<'> は多くの場合クォートされた文字列の後にある。) 例:
622345
623 local $_ = 'abcdefghi';
346 $_ = 'abcdefghi';
624347 /def/;
625348 print "$`:$&:$'\n"; # prints abc:def:ghi
626349
627350=begin original
628351
629352This variable is read-only and dynamically scoped to the current BLOCK.
630353
631354=end original
632355
633356この変数は read-only で、現在の BLOCK に動的なスコープを持ちます。
634357
635358=begin original
636359
637360The use of this variable anywhere in a program imposes a considerable
638performance penalty on all regular expression matches. See L</BUGS>.
361performance penalty on all regular expression matches. See L<BUGS>.
639362
640363=end original
641364
642365この変数をプログラムのどこかで使うと、プログラム中の全ての正規表現
643366マッチングにおいてかなりの性能低下を引き起こします。
644L</BUGS> を参照して下さい。
367L<BUGS> を参照して下さい。
645368
646=begin original
647
648See L</@-> for a replacement.
649
650=end original
651
652置き換えのためには L</@-> を参照してください。
653
654=item ${^POSTMATCH}
655X<${^POSTMATCH}>
656
657=begin original
658
659This is similar to C<$'> (C<$POSTMATCH>) except that it does not incur the
660performance penalty associated with that variable, and is only guaranteed
661to return a defined value when the pattern was compiled or executed with
662the C</p> modifier.
663
664=end original
665
666これは C<$'> (C<$POSTMATCH>) と同様ですが、この変数と関連付けられた性能上の
667ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された
668場合にのみ定義された値を返すことが保証されます。
669
670369=item $LAST_PAREN_MATCH
671370
672371=item $+
673X<$+> X<$LAST_PAREN_MATCH>
674372
675373=begin original
676374
677The text matched by the last bracket of the last successful search pattern.
375The last bracket matched by the last search pattern. This is useful if
678This is useful if you don't know which one of a set of alternative patterns
376you don't know which one of a set of alternative patterns matched. For
679matched. For example:
377example:
680378
681379=end original
682380
683381最後に検索されたパターンの最後の括弧にマッチした文字列。
684382これはいくつかの選択肢の中でどれがマッチするのか
685383わからないような場合に使うと便利です。たとえば:
686384
687385 /Version: (.*)|Revision: (.*)/ && ($rev = $+);
688386
689387=begin original
690388
691389(Mnemonic: be positive and forward looking.)
692390This variable is read-only and dynamically scoped to the current BLOCK.
693391
694392=end original
695393
696394(記憶法: ポジティブで前向き。)
697395この変数は read-only で、現在の BLOCK に動的なスコープを持ちます。
698396
699=item $LAST_SUBMATCH_RESULT
700
701=item $^N
702X<$^N>
703
704=begin original
705
706The text matched by the used group most-recently closed (i.e. the group
707with the rightmost closing parenthesis) of the last successful search
708pattern. (Mnemonic: the (possibly) Nested parenthesis that most
709recently closed.)
710
711=end original
712
713最近のマッチングに成功した検索パターンのうち、一番最近に閉じられた
714使われたグループ(つまり、一番右の閉じかっこのグループ)にマッチングした
715テキスト。
716(記憶法: もっとも最近閉じられた、(おそらく) ネストした (Nested) かっこ。)
717
718=begin original
719
720This is primarily used inside C<(?{...})> blocks for examining text
721recently matched. For example, to effectively capture text to a variable
722(in addition to C<$1>, C<$2>, etc.), replace C<(...)> with
723
724=end original
725
726これは主として最近マッチしたテキストを調べるために C<(?{...})> ブロックの
727中で使われます。
728例えば、(C<$1>, C<$2> などに加えて) テキストを変数に効率的に捕捉するには、
729C<(...)> を以下で置き換えます:
730
731 (?:(...)(?{ $var = $^N }))
732
733=begin original
734
735By setting and then using C<$var> in this way relieves you from having to
736worry about exactly which numbered set of parentheses they are.
737
738=end original
739
740C<$var> をこの方法で設定してから使うことで、かっこの組の番号について
741気にしなくてすむようになります。
742
743=begin original
744
745This variable is dynamically scoped to the current BLOCK.
746
747=end original
748
749この変数は現在の BLOCK に動的なスコープを持ちます。
750
751397=item @LAST_MATCH_END
752398
753399=item @+
754X<@+> X<@LAST_MATCH_END>
755400
756401=begin original
757402
758403This array holds the offsets of the ends of the last successful
759404submatches in the currently active dynamic scope. C<$+[0]> is
760405the offset into the string of the end of the entire match. This
761406is the same value as what the C<pos> function returns when called
762407on the variable that was matched against. The I<n>th element
763408of this array holds the offset of the I<n>th submatch, so
764409C<$+[1]> is the offset past where $1 ends, C<$+[2]> the offset
765410past where $2 ends, and so on. You can use C<$#+> to determine
766411how many subgroups were in the last successful match. See the
767412examples given for the C<@-> variable.
768413
769414=end original
770415
771416この配列は、現在アクティブな動的スコープで最後に成功した
772417サブマッチの最後へのオフセットを保持します。
773418C<$+[0]> はマッチ全体の文字列の最後へのオフセットです。
774419これはマッチした変数に対して C<pos> 関数を呼び出したときの
775420返り値と同じです。
776421この配列の I<n> 番目の要素は I<n> 番目のサブマッチのオフセットを
777422保持していますので、C<$+[1]> は過去の $1 の終わりのオフセット、
778423C<$+[2]> は $2 のオフセット、という形になります。
779424C<$#+> は最後に成功したマッチでいくつサブグループがあるかを
780425決定するのに使えます。
781426C<@-> 変数の例を参照して下さい。
782427
783=item %LAST_PAREN_MATCH
428=item $MULTILINE_MATCHING
784429
785=item %+
430=item $*
786X<%+>
787431
788432=begin original
789433
790Similar to C<@+>, the C<%+> hash allows access to the named capture
434Set to a non-zero integer value to do multi-line matching within a
791buffers, should they exist, in the last successful match in the
435string, 0 (or undefined) to tell Perl that it can assume that strings
792currently active dynamic scope.
436contain a single line, for the purpose of optimizing pattern matches.
437Pattern matches on strings containing multiple newlines can produce
438confusing results when C<$*> is 0 or undefined. Default is undefined.
439(Mnemonic: * matches multiple things.) This variable influences the
440interpretation of only C<^> and C<$>. A literal newline can be searched
441for even when C<$* == 0>.
793442
794443=end original
795444
796C<@+> と同様、C<%+> ハシュは、現在アクティブ動的スコープで最後成功
445文字列中で複数行マチを行うため非ゼロに設定
797マッチングの名前付き捕捉バッファ(存在すれば)へのアクセスを可能しま
4460 (または undef)にすると、Perl が文字列に 1 行しか無いと仮定して、
447ある種のパターンマッチに関する最適化を行なうようになります。
448複数の改行を含む文字列でのパターンマッチを
449C<$*> が 0 または undef のまま行なうと結果は信用の
450ないものになります。
451デフォルトでは undef になっています。
452(記憶法: * は複数のものにマッチします。)
453この変数は C<^> と C<$> の解釈にのみ影響します。
454リテラルの改行文字は、C<$* == 0> であっても検索することが可能です。
798455
799456=begin original
800457
801For example, C<$+{foo}> is equivalent to C<$1> after the following match:
458Use of C<$*> is deprecated in modern Perl, supplanted by
459the C</s> and C</m> modifiers on pattern matching.
802460
803461=end original
804462
805例えば、C<$+{foo}>以下のマッチングの後の C<$1> と等価です:
463最近の Perl で"$*" を使わないようにしてください。
464パターンマッチの C</s> と C</m> の修飾子に取って代わられています。
806465
807 'foo' =~ /(?<foo>foo)/;
808
809466=begin original
810467
811The keys of the C<%+> hash list only the names of buffers that have
468Assigning a non-numerical value to C<$*> triggers a warning (and makes
812captured (and that are thus associated to defined values).
469C<$*> act if C<$* == 0>), while assigning a numerical value to C<$*>
470makes that an implicit C<int> is applied on the value.
813471
814472=end original
815473
816C<%+> ハッシュのキーは捕捉された(従って定義された値と結びついてい)
474数値でない値を C<$*> に代入すと警告を引き起こします
817バッファ名前のみの一覧です。
475(そして C<$*> は C<$* == 0> ように振る舞いま)
476一方数値を C<$*> に代入すると暗黙に C<int> が値に適用されます。
818477
819=begin original
478=item input_line_number HANDLE EXPR
820479
821The underlying behaviour of C<%+> is provided by the
822L<Tie::Hash::NamedCapture> module.
823
824=end original
825
826C<%+> の基礎となる振る舞いは L<Tie::Hash::NamedCapture> モジュールで
827提供されています。
828
829=begin original
830
831B<Note:> C<%-> and C<%+> are tied views into a common internal hash
832associated with the last successful regular expression. Therefore mixing
833iterative access to them via C<each> may have unpredictable results.
834Likewise, if the last successful match changes, then the results may be
835surprising.
836
837=end original
838
839B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の
840内部ハッシュと tie されたビューです。
841従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果と
842なります。
843同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。
844
845=item HANDLE->input_line_number(EXPR)
846
847480=item $INPUT_LINE_NUMBER
848481
849482=item $NR
850483
851484=item $.
852X<$.> X<$NR> X<$INPUT_LINE_NUMBER> X<line number>
853485
854486=begin original
855487
856Current line number for the last filehandle accessed.
488The current input record number for the last file handle from which
489you just read() (or called a C<seek> or C<tell> on). The value
490may be different from the actual physical line number in the file,
491depending on what notion of "line" is in effect--see C<$/> on how
492to change that. An explicit close on a filehandle resets the line
493number. Because C<< <> >> never does an explicit close, line
494numbers increase across ARGV files (but see examples in L<perlfunc/eof>).
495Consider this variable read-only: setting it does not reposition
496the seek pointer; you'll have to do that on your own. Localizing C<$.>
497has the effect of also localizing Perl's notion of "the last read
498filehandle". (Mnemonic: many programs use "." to mean the current line
499number.)
857500
858501=end original
859502
860最後にアクセスされファイルハンドルの現在の行番号。
503最後にread() (まは C<seek> または C<tell>)を
504行なったファイルハンドルの現在の入力レコード番号。
862=begin original
505この値はファイルの実際の物理行番号とは異なるかもしれません。
506「行」とは何かによります。
864Each filehandle in Perl counts the number of lines that have been read
507これを変えるには C<$/> を参照して下さい。
865from it. (Depending on the value of C<$/>, Perl's idea of what
508明示的にファイルハンドルをクローズした場合に、行番号がリセットされます。
866constitutes a line may not match yours.) When a line is read from a
509C<< <> >> 構文では明示的にクローズを行ないませんから、ARGV
867filehandle (via readline() or C<< <> >>), or when tell() or seek() is
510ファイルに跨って行番号が数えられることになります (が、
868called on it, C<$.> becomes an alias to the line counter for that
511L<perlfunc/eof> の例を参照してください)。
869filehandle.
512この変数は読み込み専用と考えてください。
513値を設置してもシークポインタは移動しません。自力でする必要があります。
871=end original
514C<$.>を local 化すると、Perl の「最後に読んだファイルハンドル」を
515local 化する効果があります。
873Perl の各ファイルハンドルは、そこから読み込んだ行数を数えています。
874(C<$/> の値に依存して、何が行を構成するかに関する Perl の考えはあなたの
875考えと一致しないかもしれません。)
876行が(readline() や C<< <> >> を使って)ファイルハンドルから読み込まれたか、
877tell() や seek() がファイルハンドルに対して呼び出された場合、
878C<$.> はそのファイルハンドルの行カウンタへのエイリアスとなります。
879
880=begin original
881
882You can adjust the counter by assigning to C<$.>, but this will not
883actually move the seek pointer. I<Localizing C<$.> will not localize
884the filehandle's line count>. Instead, it will localize perl's notion
885of which filehandle C<$.> is currently aliased to.
886
887=end original
888
889C<$.> へ代入することでカウンタの値を修正できますが、これは実際にシーク
890ポインタを動かすことはありません。
891I<C<$.> をローカル化してもファイルハンドルの行カウンタは
892ローカル化されません>。
893代わりに、現在 C<$.> がどのファイルハンドルへのエイリアスかという情報が
894ローカル化されます。
895
896=begin original
897
898C<$.> is reset when the filehandle is closed, but B<not> when an open
899filehandle is reopened without an intervening close(). For more
900details, see L<perlop/"IE<sol>O Operators">. Because C<< <> >> never does
901an explicit close, line numbers increase across ARGV files (but see
902examples in L<perlfunc/eof>).
903
904=end original
905
906C<$.> はファイルハンドルがクローズされるとリセットされますが、
907オープンしているファイルハンドルが close() されることなく再オープンされた
908場合にはリセット B<されません>。
909さらなる詳細については、L<perlop/"IE<sol>O Operators"> を参照してください。
910なぜなら、 C<< <> >> は決して明示的なクローズは行わず、行番号は ARGV の
911ファイル間で通算してカウントされるからです(但し L<perlfunc/eof> の例を
912参照してください)。
913
914=begin original
915
916You can also use C<< HANDLE->input_line_number(EXPR) >> to access the
917line counter for a given filehandle without having to worry about
918which handle you last accessed.
919
920=end original
921
922また、C<< HANDLE->input_line_number(EXPR) >> とすることで、どのハンドルに
923最後にアクセスしたかを気にすることなく行カウンタにアクセスできます。
924
925=begin original
926
927(Mnemonic: many programs use "." to mean the current line number.)
928
929=end original
930
931516(記憶法: 多くのプログラムで "." が現在行番号を示すように使われています。)
932517
933=item IO::Handle->input_record_separator(EXPR)
518=item input_record_separator HANDLE EXPR
934519
935520=item $INPUT_RECORD_SEPARATOR
936521
937522=item $RS
938523
939524=item $/
940X<$/> X<$RS> X<$INPUT_RECORD_SEPARATOR>
941525
942526=begin original
943527
944528The input record separator, newline by default. This
945529influences Perl's idea of what a "line" is. Works like B<awk>'s RS
946530variable, including treating empty lines as a terminator if set to
947531the null string. (An empty line cannot contain any spaces
948532or tabs.) You may set it to a multi-character string to match a
949533multi-character terminator, or to C<undef> to read through the end
950534of file. Setting it to C<"\n\n"> means something slightly
951535different than setting to C<"">, if the file contains consecutive
952536empty lines. Setting to C<""> will treat two or more consecutive
953537empty lines as a single empty line. Setting to C<"\n\n"> will
954538blindly assume that the next input character belongs to the next
955539paragraph, even if it's a newline. (Mnemonic: / delimits
956540line boundaries when quoting poetry.)
957541
958542=end original
959543
960544入力レコードセパレータで、デフォルトでは改行文字。
961545これは Perl での「行」とは何か、ということに影響を与えます。
962546空文字列に設定されると、空行をセパレータとして扱うことを
963547含めて、B<awk> の変数 RS のように働きます
964548(空行はスペースやタブを含んでいてはいけません)。
965549複数文字の区切文字を示すために、文字列を設定することもできます。
966550また、ファイルの最後まで読み込むために undef を指定することもできます。
967551この変数に C<"\n\n"> を設定すると、空行が続く場合において、
968552C<""> を設定した場合とわずかに違う動作をするようになります。
969553C<""> を設定した場合には、複数の空行も 1 つの空行であるかのように扱います。
970554C<"\n\n"> を設定した場合には、単純に次の文字が (たとえ改行文字であっても)
971555次の段落に含まれるものとして扱います。
972556(記憶法: /は、詩を引用するときに、行の区切りを示します。)
973557
974 local $/; # enable "slurp" mode
558 undef $/; # enable "slurp" mode
975 local $_ = <FH>; # whole file now here
559 $_ = <FH>; # whole file now here
976560 s/\n[ \t]+/ /g;
977561
978562=begin original
979563
980564Remember: the value of C<$/> is a string, not a regex. B<awk> has to be
981565better for something. :-)
982566
983567=end original
984568
985569注意: C<$/> は文字列であり、正規表現ではありません。
986570B<awk> は何かもっとうまくやらなくてはいけません。:-)
987571
988572=begin original
989573
990574Setting C<$/> to a reference to an integer, scalar containing an integer, or
991575scalar that's convertible to an integer will attempt to read records
992576instead of lines, with the maximum record size being the referenced
993577integer. So this:
994578
995579=end original
996580
997581C<$/> に整数、整数を含むスカラ、整数に変換できるスカラのいずれかへの
998582リファレンスをセットすると、行を読む代わりにレコードを読もうとします。
999583この場合、最大レコードサイズはリファレンス先の整数値となります。つまり:
1000584
1001 local $/ = \32768; # or \"32768", or \$var_containing_32768
585 $/ = \32768; # or \"32768", or \$var_containing_32768
1002 open my $fh, "<", $myfile or die $!;
586 open(FILE, $myfile);
1003 local $_ = <$fh>;
587 $_ = <FILE>;
1004588
1005589=begin original
1006590
1007591will read a record of no more than 32768 bytes from FILE. If you're
1008592not reading from a record-oriented file (or your OS doesn't have
1009593record-oriented files), then you'll likely get a full chunk of data
1010594with every read. If a record is larger than the record size you've
1011set, you'll get the record back in pieces. Trying to set the record
595set, you'll get the record back in pieces.
1012size to zero or less will cause reading in the (rest of the) whole file.
1013596
1014597=end original
1015598
1016599これは FILE から 32768 バイトを超えないようにレコードを読み込みます。
1017600もしレコード指向のファイルを読み込まない場合
1018601(あるいは OS がレコード指向ファイルを持たない場合)、
1019602読み込み毎にデータのチャンク全部を取り込みます。
1020603もしレコードがセットしたレコードサイズより大きい場合、
1021604レコードの部分を取り込みます。
1022レコードサイズを 0 以下にセットしようとすると、(残りの)ファイル全体を
1023読み込むことになります。
1024605
1025606=begin original
1026607
1027608On VMS, record reads are done with the equivalent of C<sysread>,
1028609so it's best not to mix record and non-record reads on the same
1029610file. (This is unlikely to be a problem, because any file you'd
1030611want to read in record mode is probably unusable in line mode.)
1031612Non-VMS systems do normal I/O, so it's safe to mix record and
1032613non-record reads of a file.
1033614
1034615=end original
1035616
1036617VMS では、レコード読み込みは C<sysread> と等価に行われますので、
1037618レコード読み込みと非レコード読み込みを同じファイルで混ぜないのが
1038619最善です。(これはあまり問題になりません。なぜなら
1039620レコード読み込みしたいファイルは多分行モードでは使えないものだからです。)
1040621VMS 以外のシステムでは普通の I/O を使いますので、
1041622同じファイルのレコード読み込みと非レコード読み込みを混ぜても安全です。
1042623
1043624=begin original
1044625
1045626See also L<perlport/"Newlines">. Also see C<$.>.
1046627
1047628=end original
1048629
1049630L<perlport/"Newlines"> と C<$.> も参照してください。
1050631
1051=item HANDLE->autoflush(EXPR)
632=item autoflush HANDLE EXPR
1052633
1053634=item $OUTPUT_AUTOFLUSH
1054635
1055636=item $|
1056X<$|> X<autoflush> X<flush> X<$OUTPUT_AUTOFLUSH>
1057637
1058638=begin original
1059639
1060640If set to nonzero, forces a flush right away and after every write
1061641or print on the currently selected output channel. Default is 0
1062642(regardless of whether the channel is really buffered by the
1063643system or not; C<$|> tells you only whether you've asked Perl
1064644explicitly to flush after each write). STDOUT will
1065645typically be line buffered if output is to the terminal and block
1066646buffered otherwise. Setting this variable is useful primarily when
1067647you are outputting to a pipe or socket, such as when you are running
1068648a Perl program under B<rsh> and want to see the output as it's
1069649happening. This has no effect on input buffering. See L<perlfunc/getc>
1070for that. See L<perldoc/select> on how to select the output channel.
650for that. (Mnemonic: when you want your pipes to be piping hot.)
1071See also L<IO::Handle>. (Mnemonic: when you want your pipes to be piping hot.)
1072651
1073652=end original
1074653
10756540 以外に設定されると、
1076655その時点で選択されている出力チャネルを
1077656直ちにその場でフラッシュし、
1078657さらに write や print を行なうごとに、強制的にフラッシュします。
1079658デフォルトでは 0 となっています
1080659(チャンネルが実際にシステムによってバッファリングされているかどうかは
1081660関知しません。C<$|> は Perl が明示的に毎回書き込みの後に
1082661フラッシュするかどうかのみを示します)。
1083662STDOUT は通常では、端末への出力時には行バッファリング、
1084663それ以外ではブロックバッファリングであることに注意してください。
1085664これは、Perl のスクリプトを rsh 配下で実行して、
1086実行状況を確認したい場合のように、パイプやソケットに出力するときに特に
665実行状況を確認したい場合のように、パイプやソケットに出力するときに特に便利でしょう。
1087便利でしょう。
1088666これは入力バッファリングには何の影響も与えません。
1089出力チャネルの選択方法については L<perldoc/select> を参照してください。
1090L<IO::Handle> も参照してください。
1091667(記憶法: パイプをホットな状態にしておくために使う。)
1092668
1093=item IO::Handle->output_field_separator EXPR
669=item output_field_separator HANDLE EXPR
1094670
1095671=item $OUTPUT_FIELD_SEPARATOR
1096672
1097673=item $OFS
1098674
1099675=item $,
1100X<$,> X<$OFS> X<$OUTPUT_FIELD_SEPARATOR>
1101676
1102677=begin original
1103678
1104The output field separator for the print operator. If defined, this
679The output field separator for the print operator. Ordinarily the
1105value is printed between each of print's arguments. Default is C<undef>.
680print operator simply prints out its arguments without further
1106(Mnemonic: what is printed when there is a "," in your print statement.)
681adornment. To get behavior more like B<awk>, set this variable as
682you would set B<awk>'s OFS variable to specify what is printed
683between fields. (Mnemonic: what is printed when there is a "," in
684your print statement.)
1107685
1108686=end original
1109687
1110688print 演算子のための出力フィールドセパレータ。
1111定義されると、この値がそれぞれの print 引数の間表示されます。
689通常 print 演算子は、引数を修飾なしで単純印字します。
1112デフォルトは C<undef> です。
690より、B<awk> に近い動作をさせるには、
691フィールドの区切りとして印字されるものとして B<awk> の
692変数 OFS に設定するものを、この変数に設定します。
1113693(記憶法: print 文で "," を書いた場所に印字されるもの。)
1114694
1115=item IO::Handle->output_record_separator EXPR
695=item output_record_separator HANDLE EXPR
1116696
1117697=item $OUTPUT_RECORD_SEPARATOR
1118698
1119699=item $ORS
1120700
1121701=item $\
1122X<$\> X<$ORS> X<$OUTPUT_RECORD_SEPARATOR>
1123702
1124703=begin original
1125704
1126The output record separator for the print operator. If defined, this
705The output record separator for the print operator. Ordinarily the
1127value is printed after the last of print's arguments. Default is C<undef>.
706print operator simply prints out its arguments as is, with no
1128(Mnemonic: you set C<$\> instead of adding "\n" at the end of the print.
707trailing newline or other end-of-record string added. To get
1129Also, it's just like C<$/>, but it's what you get "back" from Perl.)
708behavior more like B<awk>, set this variable as you would set
709B<awk>'s ORS variable to specify what is printed at the end of the
710print. (Mnemonic: you set C<$\> instead of adding "\n" at the
711end of the print. Also, it's just like C<$/>, but it's what you
712get "back" from Perl.)
1130713
1131714=end original
1132715
1133716print 演算子のための出力レコードセパレータ。
1134もし定義されていると、print の最後の引数の最後この値が表示されます。
717通常print 演算子は、引数を単純印字し、
1135デフォルトは C<undef> です
718改行などレコード終わりの文字列をつけません
719より B<awk> に近い動作をさせるには、
720print の最後に印字されるものとして B<awk> の変数 ORS に
721設定するものを、この変数に設定します。
1136722(記憶法: print の最後に "\n" を付け加える代わりに C<$\> を設定する。
1137723また、C<$/> に似通っているが、Perl から「バック」されるものです。)
1138724
1139725=item $LIST_SEPARATOR
1140726
1141727=item $"
1142X<$"> X<$LIST_SEPARATOR>
1143728
1144729=begin original
1145730
1146731This is like C<$,> except that it applies to array and slice values
1147732interpolated into a double-quoted string (or similar interpreted
1148733string). Default is a space. (Mnemonic: obvious, I think.)
1149734
1150735=end original
1151736
1152737C<$,> と同様ですが、これは 2 重引用符で括られた文字列
1153738(または、同様に扱われる文字列) 内で配列とスライスの値が展開される
1154739際に適用されます。
1155740デフォルトではスペースになっています。(記憶法: 明らかでしょう。)
1156741
1157742=item $SUBSCRIPT_SEPARATOR
1158743
1159744=item $SUBSEP
1160745
1161746=item $;
1162X<$;> X<$SUBSEP> X<SUBSCRIPT_SEPARATOR>
1163747
1164748=begin original
1165749
1166750The subscript separator for multidimensional array emulation. If you
1167751refer to a hash element as
1168752
1169=end original
1170
1171多次元配列のエミュレートのための添え字の区切文字。
1172ハッシュの要素を
1173
1174753 $foo{$a,$b,$c}
1175754
1176=begin original
1177
1178755it really means
1179756
1180=end original
757 $foo{join($;, $a, $b, $c)}
1181758
1182のようにして参照すると、実際には
759But don't put
1183760
1184 $foo{join($;, $a, $b, $c)}
761 @foo{$a,$b,$c} # a slice--note the @
1185762
1186=begin original
763which means
1187764
1188But don't put
765 ($foo{$a},$foo{$b},$foo{$c})
1189766
1190767=end original
1191768
1192という意味になります
769多次元配列のエミュレートのための添え字の区切文字
1193しかし、
770ハッシュの要素を
1194771
1195 @foo{$a,$b,$c} # a slice--note the @
772 $foo{$a,$b,$c}
1196773
1197=begin original
774のようにして参照すると、実際には
1198775
1199which means
776 $foo{join($;, $a, $b, $c)}
1200777
1201=end original
778という意味になります。 しかし、
1202779
1203としてはいけません。
780 @foo{$a,$b,$c} # スライス -- @ に注意
1204これは以下の意味になります。
1205781
782としてはいけません。これは以下の意味になります。
783
1206784 ($foo{$a},$foo{$b},$foo{$c})
1207785
1208786=begin original
1209787
1210788Default is "\034", the same as SUBSEP in B<awk>. If your
1211789keys contain binary data there might not be any safe value for C<$;>.
1212790(Mnemonic: comma (the syntactic subscript separator) is a
1213791semi-semicolon. Yeah, I know, it's pretty lame, but C<$,> is already
1214792taken for something more important.)
1215793
1216794=end original
1217795
1218796デフォルトは "\034" で、C<awk> の SUBSEP と同じです。
1219797使おうとしている key の値がバイナリのデータを含むならば、
1220798C<$;> に設定する安全な値などはないことになります。
1221799(記憶法: コンマ (構文上の添え字区切り文字) は
1222800セミ−セミコロンなのです。
1223801ええ、詭弁だとはわかってますが、C<$,> はもう既にもっと
1224802重要な任務を持ってるんです。)
1225803
1226804=begin original
1227805
1228806Consider using "real" multidimensional arrays as described
1229807in L<perllol>.
1230808
1231809=end original
1232810
1233811L<perllol> で記述している「本物の」多次元配列を使うようにしてください。
1234812
1235=item HANDLE->format_page_number(EXPR)
813=item $OFMT
1236814
815=item $#
816
817=begin original
818
819The output format for printed numbers. This variable is a half-hearted
820attempt to emulate B<awk>'s OFMT variable. There are times, however,
821when B<awk> and Perl have differing notions of what counts as
822numeric. The initial value is "%.I<n>g", where I<n> is the value
823of the macro DBL_DIG from your system's F<float.h>. This is different from
824B<awk>'s default OFMT setting of "%.6g", so you need to set C<$#>
825explicitly to get B<awk>'s value. (Mnemonic: # is the number sign.)
826
827=end original
828
829数字を印字する際の出力フォーマット。
830この変数は、不十分ではありますが、B<awk> の変数 OFMT を
831エミュレートしようとするものです。
832しかしながら、B<awk> と Perl は異なる記法で数値を表わしています。
833また、初期値は"%.I<n>g" で、ここで I<n> はシステムの F<float.h> で
834定義されているマクロ DBL_DIG の値です。
835これはB<awk> のOFMT のデフォルト値である "%.6g" と異なっていますので、
836awk での値を得るには、明示的に C<$#> を設定する必要があります。
837(記憶法: # は数値記号です。)
838
839=begin original
840
841Use of C<$#> is deprecated.
842
843=end original
844
845C<$#> は古いものなので使わないようにしてください。
846
847=item format_page_number HANDLE EXPR
848
1237849=item $FORMAT_PAGE_NUMBER
1238850
1239851=item $%
1240X<$%> X<$FORMAT_PAGE_NUMBER>
1241852
1242853=begin original
1243854
1244855The current page number of the currently selected output channel.
1245856Used with formats.
1246857(Mnemonic: % is page number in B<nroff>.)
1247858
1248859=end original
1249860
1250861その時点で選択されている出力チャネルの、その時点でのページ番号。
1251862フォーマットで用いられます。
1252863(記憶法: % は、B<nroff> でのページ番号です。)
1253864
1254=item HANDLE->format_lines_per_page(EXPR)
865=item format_lines_per_page HANDLE EXPR
1255866
1256867=item $FORMAT_LINES_PER_PAGE
1257868
1258869=item $=
1259X<$=> X<$FORMAT_LINES_PER_PAGE>
1260870
1261871=begin original
1262872
1263873The current page length (printable lines) of the currently selected
1264874output channel. Default is 60.
1265875Used with formats.
1266876(Mnemonic: = has horizontal lines.)
1267877
1268878=end original
1269879
1270880その時点で選択されている出力チャネルの、その時点での
1271881ページ長 (印字可能行数)。デフォルトは 60 です。
1272882フォーマットで用いられます。
1273883(記憶法: = には複数の水平線 (行) が含まれます。)
1274884
1275=item HANDLE->format_lines_left(EXPR)
885=item format_lines_left HANDLE EXPR
1276886
1277887=item $FORMAT_LINES_LEFT
1278888
1279889=item $-
1280X<$-> X<$FORMAT_LINES_LEFT>
1281890
1282891=begin original
1283892
1284893The number of lines left on the page of the currently selected output
1285894channel.
1286895Used with formats.
1287896(Mnemonic: lines_on_page - lines_printed.)
1288897
1289898=end original
1290899
1291900その時点で選択されている出力チャネルの、ページに残っている行数。
1292901フォーマットで用いられます。
1293902(記憶法: "ページ行数" - "印字済み行数")
1294903
1295904=item @LAST_MATCH_START
1296905
1297906=item @-
1298X<@-> X<@LAST_MATCH_START>
1299907
1300908=begin original
1301909
1302910$-[0] is the offset of the start of the last successful match.
1303911C<$-[>I<n>C<]> is the offset of the start of the substring matched by
1304912I<n>-th subpattern, or undef if the subpattern did not match.
1305913
1306914=end original
1307915
1308916$-[0] は最後に成功したマッチの先頭のオフセットです。
1309917C<$-[>I<n>C<]> は I<n> 番目のサブパターンにマッチした部分文字列の
1310918先頭のオフセットです。サブパターンがマッチしなかった場合は undef です。
1311919
1312920=begin original
1313921
1314922Thus after a match against $_, $& coincides with C<substr $_, $-[0],
1315$+[0] - $-[0]>. Similarly, $I<n> coincides with C<substr $_, $-[n],
923$+[0] - $-[0]>. Similarly, C<$>I<n> coincides with C<substr $_, $-[>I<n>C<],
1316$+[n] - $-[n]> if C<$-[n]> is defined, and $+ coincides with
924$+[>I<n>C<] - $-[>I<n>C<]> if C<$-[>I<n>C<]> is defined, and $+ coincides with
1317C<substr $_, $-[$#-], $+[$#-] - $-[$#-]>. One can use C<$#-> to find the last
925C<substr $_, $-[$#-], $+[$#-]>. One can use C<$#-> to find the last
1318926matched subgroup in the last successful match. Contrast with
1319927C<$#+>, the number of subgroups in the regular expression. Compare
1320928with C<@+>.
1321929
1322930=end original
1323931
1324932従って $_ のマッチの後、$& は C<substr $_, $-[0], $+[0] - $-[0]> と
1325一致します。同様に、$I<n> は、C<$-[n]> が定義されていれば
933一致します。同様に、C<$>I<n> は、C<$-[>I<n>C<]> が定義されていれば
1326C<substr $_, $-[n], $+[n] - $-[n]> と一致し、
934C<substr $_, $-[>I<n>C<], $+[>I<n>C<] - $-[>I<n>C<]> と一致し、
1327$+ は C<substr $_, $-[$#-], $+[$#-] - $-[$#-]> と一致します。
935$+ は C<substr $_, $-[$#-], $+[$#-]> と一致します。
1328936C<$#-> は直前に成功したマッチで最後のマッチしたサブグループを
1329937探すのに使えます。
1330938正規表現でのサブグループの数である C<$#+> と対照的です。
1331939C<@+> と比較してください。
1332940
1333941=begin original
1334942
1335943This array holds the offsets of the beginnings of the last
1336944successful submatches in the currently active dynamic scope.
1337945C<$-[0]> is the offset into the string of the beginning of the
1338946entire match. The I<n>th element of this array holds the offset
1339of the I<n>th submatch, so C<$-[1]> is the offset where $1
947of the I<n>th submatch, so C<$+[1]> is the offset where $1
1340begins, C<$-[2]> the offset where $2 begins, and so on.
948begins, C<$+[2]> the offset where $2 begins, and so on.
949You can use C<$#-> to determine how many subgroups were in the
950last successful match. Compare with the C<@+> variable.
1341951
1342952=end original
1343953
1344954この配列は現在アクティブな動的スコープ内で最後に成功した
1345955サブマッチの先頭位置のオフセットを保持します。
1346956C<$-[0]> はマッチ全体の先頭の文字列へのオフセットです。
1347957この配列の I<n> 番目の要素は I<n> 番目のサブマッチへの
1348オフセットを保持しますので、C<$-[1]> は $1 の先頭への
958オフセットを保持しますので、C<$+[1]> は $1 の先頭への
1349オフセット、C<$-[2]> は $2 の先頭へのオフセット、などとなります。
959オフセット、C<$+[2]> は $2 の先頭へのオフセット、などとなります。
960C<$#-> を、最後に成功したマッチでいくつのサブグループがあるのかを
961決定するのに使えます。
962C<@+> 変数と比較してください。
1350963
1351964=begin original
1352965
1353966After a match against some variable $var:
1354967
1355968=end original
1356969
1357970ある変数 $var でマッチした後、以下のようになります。
1358971
1359972=begin original
1360973
1361974=over 5
1362975
1363976=item C<$`> is the same as C<substr($var, 0, $-[0])>
1364977
1365978=item C<$&> is the same as C<substr($var, $-[0], $+[0] - $-[0])>
1366979
1367980=item C<$'> is the same as C<substr($var, $+[0])>
1368981
1369982=item C<$1> is the same as C<substr($var, $-[1], $+[1] - $-[1])>
1370983
1371984=item C<$2> is the same as C<substr($var, $-[2], $+[2] - $-[2])>
1372985
1373=item C<$3> is the same as C<substr($var, $-[3], $+[3] - $-[3])>
986=item C<$3> is the same as C<substr $var, $-[3], $+[3] - $-[3])>
1374987
1375988=back
1376989
1377990=end original
1378991
1379992=over 5
1380993
1381994=item C<$`> は C<substr($var, 0, $-[0])> と同じです。
1382995
1383996=item C<$&> は C<substr($var, $-[0], $+[0] - $-[0])> と同じです。
1384997
1385998=item C<$'> は C<substr($var, $+[0])> と同じです。
1386999
13871000=item C<$1> は C<substr($var, $-[1], $+[1] - $-[1])> と同じです。
13881001
13891002=item C<$2> は C<substr($var, $-[2], $+[2] - $-[2])> と同じです。
13901003
13911004=item C<$3> は C<substr $var, $-[3], $+[3] - $-[3])> と同じです。
13921005
13931006=back
13941007
1395=item %-
1008=item format_name HANDLE EXPR
1396X<%->
13971009
1398=begin original
1399
1400Similar to C<%+>, this variable allows access to the named capture buffers
1401in the last successful match in the currently active dynamic scope. To
1402each capture buffer name found in the regular expression, it associates a
1403reference to an array containing the list of values captured by all
1404buffers with that name (should there be several of them), in the order
1405where they appear.
1406
1407=end original
1408
1409C<%+> と同様、この変数は現在アクティブな動的スコープで最後に成功した
1410マッチングの名前付き捕捉バッファへのアクセスを可能にします。
1411正規表現中に捕捉バッファ名が現れるごとに、その名前のバッファ全てで
1412(複数あるでしょう)捕捉されている値のリストを出現順で含む配列への
1413リファレンスと関連付けられます。
1414
1415=begin original
1416
1417Here's an example:
1418
1419=end original
1420
1421以下に例を示します:
1422
1423 if ('1234' =~ /(?<A>1)(?<B>2)(?<A>3)(?<B>4)/) {
1424 foreach my $bufname (sort keys %-) {
1425 my $ary = $-{$bufname};
1426 foreach my $idx (0..$#$ary) {
1427 print "\$-{$bufname}[$idx] : ",
1428 (defined($ary->[$idx]) ? "'$ary->[$idx]'" : "undef"),
1429 "\n";
1430 }
1431 }
1432 }
1433
1434=begin original
1435
1436would print out:
1437
1438=end original
1439
1440とすると、以下のものが表示されます:
1441
1442 $-{A}[0] : '1'
1443 $-{A}[1] : '3'
1444 $-{B}[0] : '2'
1445 $-{B}[1] : '4'
1446
1447=begin original
1448
1449The keys of the C<%-> hash correspond to all buffer names found in
1450the regular expression.
1451
1452=end original
1453
1454C<%-> ハッシュのキーは正規表現で見つかった全てのバッファ名に対応します。
1455
1456=begin original
1457
1458The behaviour of C<%-> is implemented via the
1459L<Tie::Hash::NamedCapture> module.
1460
1461=end original
1462
1463C<%-> の振る舞いは L<Tie::Hash::NamedCapture> モジュールを使って
1464実装されています。
1465
1466=begin original
1467
1468B<Note:> C<%-> and C<%+> are tied views into a common internal hash
1469associated with the last successful regular expression. Therefore mixing
1470iterative access to them via C<each> may have unpredictable results.
1471Likewise, if the last successful match changes, then the results may be
1472surprising.
1473
1474=end original
1475
1476B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の
1477内部ハッシュと tie されたビューです。
1478従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果と
1479なります。
1480同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。
1481
1482=item HANDLE->format_name(EXPR)
1483
14841010=item $FORMAT_NAME
14851011
14861012=item $~
1487X<$~> X<$FORMAT_NAME>
14881013
14891014=begin original
14901015
14911016The name of the current report format for the currently selected output
14921017channel. Default is the name of the filehandle. (Mnemonic: brother to
14931018C<$^>.)
14941019
14951020=end original
14961021
14971022その時点で選択されている出力チャネルの、その時点でのフォーマット名。
14981023デフォルトでは、ファイルハンドルと同名です。
14991024(記憶法: C<$^> の兄弟。)
15001025
1501=item HANDLE->format_top_name(EXPR)
1026=item format_top_name HANDLE EXPR
15021027
15031028=item $FORMAT_TOP_NAME
15041029
15051030=item $^
1506X<$^> X<$FORMAT_TOP_NAME>
15071031
15081032=begin original
15091033
15101034The name of the current top-of-page format for the currently selected
15111035output channel. Default is the name of the filehandle with _TOP
15121036appended. (Mnemonic: points to top of page.)
15131037
15141038=end original
15151039
15161040その時点で選択されている出力チャネルの、その時点での
15171041ページ先頭フォーマット名。
15181042デフォルトでは、ファイルハンドル名に _TOP を続けたもの。
15191043(記憶法: ページの先頭へのポインタ。)
15201044
1521=item IO::Handle->format_line_break_characters EXPR
1045=item format_line_break_characters HANDLE EXPR
15221046
15231047=item $FORMAT_LINE_BREAK_CHARACTERS
15241048
15251049=item $:
1526X<$:> X<FORMAT_LINE_BREAK_CHARACTERS>
15271050
15281051=begin original
15291052
15301053The current set of characters after which a string may be broken to
15311054fill continuation fields (starting with ^) in a format. Default is
15321055S<" \n-">, to break on whitespace or hyphens. (Mnemonic: a "colon" in
15331056poetry is a part of a line.)
15341057
15351058=end original
15361059
15371060フォーマットの充填継続フィールド (^ で始まるもの) への
15381061文字列で行分割を許す文字集合。
15391062デフォルトは S<" \n-"> で空白か改行の後で行分割が可能となっています。
15401063(記憶法: 詩では「コロン」は、行の一部。)
15411064
1542=item IO::Handle->format_formfeed EXPR
1065=item format_formfeed HANDLE EXPR
15431066
15441067=item $FORMAT_FORMFEED
15451068
15461069=item $^L
1547X<$^L> X<$FORMAT_FORMFEED>
15481070
15491071=begin original
15501072
15511073What formats output as a form feed. Default is \f.
15521074
15531075=end original
15541076
15551077フォーマット出力で、改ページのために出力されるもの。
15561078デフォルトは \f。
15571079
15581080=item $ACCUMULATOR
15591081
15601082=item $^A
1561X<$^A> X<$ACCUMULATOR>
15621083
15631084=begin original
15641085
15651086The current value of the write() accumulator for format() lines. A format
15661087contains formline() calls that put their result into C<$^A>. After
15671088calling its format, write() prints out the contents of C<$^A> and empties.
15681089So you never really see the contents of C<$^A> unless you call
15691090formline() yourself and then look at it. See L<perlform> and
15701091L<perlfunc/formline()>.
15711092
15721093=end original
15731094
15741095format() 行のための、その時点での write() アキュムレータの値。
15751096format には、C<$^A> に結果を残す、formline() 呼び出しが含まれます。
15761097自分のフォーマットを呼び出した後で、
15771098write() は C<$^A> の内容を出力してから消去します。
15781099したがって、自分で formline() を呼び出すのでなければ、
15791100C<$^A> の値が見えることはありません。
15801101L<perlform> と L<perlfunc/formline()> を参照してください。
15811102
15821103=item $CHILD_ERROR
15831104
15841105=item $?
1585X<$?> X<$CHILD_ERROR>
15861106
15871107=begin original
15881108
15891109The status returned by the last pipe close, backtick (C<``>) command,
15901110successful call to wait() or waitpid(), or from the system()
15911111operator. This is just the 16-bit status word returned by the
1592traditional Unix wait() system call (or else is made up to look like it). Thus, the
1112wait() system call (or else is made up to look like it). Thus, the
15931113exit value of the subprocess is really (C<<< $? >> 8 >>>), and
15941114C<$? & 127> gives which signal, if any, the process died from, and
15951115C<$? & 128> reports whether there was a core dump. (Mnemonic:
15961116similar to B<sh> and B<ksh>.)
15971117
15981118=end original
15991119
16001120最後に close したパイプ、バッククォート (C<``>) コマンド、
16011121成功した wait() または waitpid() 呼び出し、system() 演算子が返したステータス。
1602このステータスワードは伝統的な Unix の wait() システムコールが返した
1122このステータスワードは wait() システムコールが返した
1603112316 ビットのステータス(またはそのように見えるもの)です。
16041124従ってサブプロセスの exit 値は、実際には (C<<< $? >> 8 >>>)
16051125で、C<$? & 127> は、もしあれば、そのプロセスを止めたシグナルで、
16061126C<$? & 128> はコアダンプがあるかどうかを示します。
16071127(記憶法: B<sh> や B<ksh> と同様。)
16081128
16091129=begin original
16101130
16111131Additionally, if the C<h_errno> variable is supported in C, its value
16121132is returned via $? if any C<gethost*()> function fails.
16131133
16141134=end original
16151135
16161136さらに、C で C<h_errno> 変数に対応している場合は、
16171137C<gethost*()> が失敗したときに $? を通して返されます。
16181138
16191139=begin original
16201140
16211141If you have installed a signal handler for C<SIGCHLD>, the
16221142value of C<$?> will usually be wrong outside that handler.
16231143
16241144=end original
16251145
16261146C<SIGCHLD> のシグナルハンドラを設定した場合、
16271147C<$?> の値は通常ハンドラの外側では正しくない値となります。
16281148
16291149=begin original
16301150
16311151Inside an C<END> subroutine C<$?> contains the value that is going to be
16321152given to C<exit()>. You can modify C<$?> in an C<END> subroutine to
16331153change the exit status of your program. For example:
16341154
16351155=end original
16361156
16371157C<END> サブルーチンの内側では C<$?> には C<exit()> に渡されようとしている
16381158値を含みます。
16391159プログラムの終了ステータスを変更するために、C<END> サブルーチン 内で
16401160C<$?> を変更できます。
16411161例えば:
16421162
16431163 END {
16441164 $? = 1 if $? == 255; # die would make it 255
16451165 }
16461166
16471167=begin original
16481168
16491169Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect the
16501170actual VMS exit status, instead of the default emulation of POSIX
1651status; see L<perlvms/$?> for details.
1171status.
16521172
16531173=end original
16541174
16551175VMS では、C<use vmsish 'status'> を指定すると、
16561176C<$?> はPOSIX ステータスをエミュレートしたものではなく、
1657実際の VMS 終了ステータスを反映します; 詳細は L<perlvms/$?> を
1177実際の VMS 終了ステータスを反映します
1658参照してください。
16591178
16601179=begin original
16611180
16621181Also see L<Error Indicators>.
16631182
16641183=end original
16651184
16661185L<Error Indicators> も参照して下さい。
16671186
1668=item ${^CHILD_ERROR_NATIVE}
1669X<$^CHILD_ERROR_NATIVE>
1670
1671=begin original
1672
1673The native status returned by the last pipe close, backtick (C<``>)
1674command, successful call to wait() or waitpid(), or from the system()
1675operator. On POSIX-like systems this value can be decoded with the
1676WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG
1677and WIFCONTINUED functions provided by the L<POSIX> module.
1678
1679=end original
1680
1681The native status returned by
1682最後のパイプクローズ、逆クォート (C<``>) コマンド、wait() と waitpid() の
1683成功した呼び出し、system() 演算子から返された、ネイティブなステータスです。
1684POSIX 風システムでは、この値は L<POSIX> モジュールで提供される
1685WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG,
1686WIFCONTINUED 関数でデコードできます。
1687
1688=begin original
1689
1690Under VMS this reflects the actual VMS exit status; i.e. it is the same
1691as $? when the pragma C<use vmsish 'status'> is in effect.
1692
1693=end original
1694
1695VMS ではこれは実際の VMS の終了ステータスを反映します;
1696言い換えると、これは C<use vmsish 'status'> プラグマが有効なときの $? と
1697同じです。
1698
1699=item ${^ENCODING}
1700X<$^ENCODING>
1701
1702=begin original
1703
1704The I<object reference> to the Encode object that is used to convert
1705the source code to Unicode. Thanks to this variable your perl script
1706does not have to be written in UTF-8. Default is I<undef>. The direct
1707manipulation of this variable is highly discouraged.
1708
1709=end original
1710
1711ソースコードを Unicode に変換するために使われる Encode オブジェクトへの
1712I<オブジェクトリファレンス> 。
1713この変数のおかげで、perl スクリプトを UTF-8 で書く必要がありません。
1714デフォルトは I<undef> 。
1715この変数を直接操作することはとても推奨できません。
1716
17171187=item $OS_ERROR
17181188
17191189=item $ERRNO
17201190
17211191=item $!
1722X<$!> X<$ERRNO> X<$OS_ERROR>
17231192
17241193=begin original
17251194
17261195If used numerically, yields the current value of the C C<errno>
1727variable, or in other words, if a system or library call fails, it
1196variable, with all the usual caveats. (This means that you shouldn't
1728sets this variable. This means that the value of C<$!> is meaningful
1197depend on the value of C<$!> to be anything in particular unless
1729only I<immediately> after a B<failure>:
1198you've gotten a specific error return indicating a system error.)
1199If used an a string, yields the corresponding system error string.
1731=end original
1732
1733数値として使われると、その時点の C の C<errno> 変数の値が得られます;
1734言い換えると、もしシステムコールやライブラリ呼び出しが失敗すると、
1735この変数がセットされます。
1736これは、C<$!> の値が意味を持つのは B<失敗> の I<直後> だけということを
1737意味します。
1738
1739 if (open my $fh, "<", $filename) {
1740 # Here $! is meaningless.
1741 ...
1742 } else {
1743 # ONLY here is $! meaningful.
1744 ...
1745 # Already here $! might be meaningless.
1746 }
1747 # Since here we might have either success or failure,
1748 # here $! is meaningless.
1749
1750=begin original
1751
1752In the above I<meaningless> stands for anything: zero, non-zero,
1753C<undef>. A successful system or library call does B<not> set
1754the variable to zero.
1755
1756=end original
1757
1758上記の I<meaningless> は何でもあり得ます: 0、非 0、C<undef>。
1759システムコールやライブラリ呼び出しが成功した場合は、この変数は 0 に
1760セット B<されません>。
1761
1762=begin original
1763
1764If used as a string, yields the corresponding system error string.
17651200You can assign a number to C<$!> to set I<errno> if, for instance,
17661201you want C<"$!"> to return the string for error I<n>, or you want
17671202to set the exit value for the die() operator. (Mnemonic: What just
17681203went bang?)
17691204
17701205=end original
17711206
1207数値として使われると、その時点の C の C<errno> 変数の値が
1208(通常の注意事項と共に) 得られます。
1209(これは、システムエラーを示す特定のエラーが得られた場合でもなければ、
1210C<$!> の値が、特に何かを示すものであると、頼ってはならないということです。)
17721211文字列として使われると、対応するシステムエラーのメッセージ文字列が得られます。
17731212たとえば、C<$!> にエラーの文字列を返して欲しいならば、あるいは、
17741213die() 演算子の exit 値を設定するために、I<errno> を設定するため
17751214C<$!> へ代入を行なうことが可能です。
17761215(記憶法: 何が bang(!) したか。)
17771216
17781217=begin original
17791218
17801219Also see L<Error Indicators>.
17811220
17821221=end original
17831222
17841223L<Error Indicators> も参照して下さい。
17851224
1786=item %OS_ERROR
1787
1788=item %ERRNO
1789
1790=item %!
1791X<%!>
1792
1793=begin original
1794
1795Each element of C<%!> has a true value only if C<$!> is set to that
1796value. For example, C<$!{ENOENT}> is true if and only if the current
1797value of C<$!> is C<ENOENT>; that is, if the most recent error was
1798"No such file or directory" (or its moral equivalent: not all operating
1799systems give that exact error, and certainly not all languages).
1800To check if a particular key is meaningful on your system, use
1801C<exists $!{the_key}>; for a list of legal keys, use C<keys %!>.
1802See L<Errno> for more information, and also see above for the
1803validity of C<$!>.
1804
1805=end original
1806
1807C<%!> の各要素は、C<$!> がその値にセットされている場合にのみ真の値を
1808持ちます。
1809例えば、C<$!{ENOENT}> は、現在の C<$!> の値が C<ENOENT> の場合にのみ
1810真となります; これは、最近のエラーが
1811"No such file or directory" (あるいは倫理的に等価なもの: 全ての OS が正確に
1812同じエラーを出すわけではないですし、全ての言語で出るわけでもありません) の
1813場合です。
1814あなたのシステムで特定のキーが意味があるかどうかを調べるには、
1815C<exists $!{the_key}> を使ってください; 有効なキーのリストを得るには、
1816C<keys %!> としてください。
1817さらなる情報と、C<$!> のバラエティに関しては、L<Errno> を参照してください。
1818
18191225=item $EXTENDED_OS_ERROR
18201226
18211227=item $^E
1822X<$^E> X<$EXTENDED_OS_ERROR>
18231228
18241229=begin original
18251230
18261231Error information specific to the current operating system. At
18271232the moment, this differs from C<$!> under only VMS, OS/2, and Win32
18281233(and for MacPerl). On all other platforms, C<$^E> is always just
18291234the same as C<$!>.
18301235
18311236=end original
18321237
18331238現在のオペレーティングシステムに特化したエラー情報です。
18341239現在のところ、VMS, OS/2, Win32 (と MacPerl) のみで
18351240C<$!> と異なる値をもちます。
18361241その他のプラットフォームでは、C<$^E> はいつも C<$!> と同じです。
18371242
18381243=begin original
18391244
18401245Under VMS, C<$^E> provides the VMS status value from the last
18411246system error. This is more specific information about the last
18421247system error than that provided by C<$!>. This is particularly
18431248important when C<$!> is set to B<EVMSERR>.
18441249
18451250=end original
18461251
18471252VMS では、C<$^E> は最後のシステムエラーの VMS ステータス値です。
18481253これは、最後のシステムエラーについて C<$!> で提供されるものより
18491254具体的な情報を示します。
18501255これは特に C<$!> が B<EVMSERR> にセットされた場合に重要です。
18511256
18521257=begin original
18531258
18541259Under OS/2, C<$^E> is set to the error code of the last call to
18551260OS/2 API either via CRT, or directly from perl.
18561261
18571262=end original
18581263
18591264OS/2 では、C<$^E> は CRT 経由、または Perl から直接呼び出された
18601265最後の OS/2 API のエラーコードがセットされます。
18611266
18621267=begin original
18631268
18641269Under Win32, C<$^E> always returns the last error information
18651270reported by the Win32 call C<GetLastError()> which describes
18661271the last error from within the Win32 API. Most Win32-specific
18671272code will report errors via C<$^E>. ANSI C and Unix-like calls
18681273set C<errno> and so most portable Perl code will report errors
18691274via C<$!>.
18701275
18711276=end original
18721277
18731278Win32 では、C<$^E> は Win32 API での最後のエラーの内容を返す
18741279C<GetLastError()> Win32 呼び出しで報告される最新のエラー情報を
18751280返します。
18761281ほとんどの Win32 固有のコードはエラーを C<$^E> 経由で返します。
18771282ANSI C と Unix 風の呼び出しは C<errno> をセットするので、
18781283ほとんどの移植性のある Perl コードは C<$!> 経由で
18791284エラーを報告します。
18801285
18811286=begin original
18821287
18831288Caveats mentioned in the description of C<$!> generally apply to
18841289C<$^E>, also. (Mnemonic: Extra error explanation.)
18851290
18861291=end original
18871292
18881293C<$!> の説明で触れた問題点は一般的に C<$^E> にも適用されます。
18891294(記憶法: 追加の(Extra)エラーの説明。)
18901295
18911296=begin original
18921297
18931298Also see L<Error Indicators>.
18941299
18951300=end original
18961301
18971302L<Error Indicators> も参照して下さい。
18981303
18991304=item $EVAL_ERROR
19001305
19011306=item $@
1902X<$@> X<$EVAL_ERROR>
19031307
19041308=begin original
19051309
1906The Perl syntax error message from the last eval() operator.
1310The Perl syntax error message from the last eval() operator. If null, the
1907If $@ is the null string, the last eval() parsed and executed
1311last eval() parsed and executed correctly (although the operations you
1908correctly (although the operations you invoked may have failed in the
1312invoked may have failed in the normal fashion). (Mnemonic: Where was
1909normal fashion). (Mnemonic: Where was the syntax error "at"?)
1313the syntax error "at"?)
19101314
19111315=end original
19121316
19131317最後の eval() 操作子による Perl の構文エラーメッセージです。
1914$@ が空文字列であれば、最後の eval() が正常に
1318空文字列であれば、最後の eval() が正常に
19151319解析され、実行されたことになります (が、実行した演算子が、
19161320通常の意味で失敗しているかもしれません)。
19171321(記憶法: どこで ("at" where) 構文エラーが起ったか。)
19181322
19191323=begin original
19201324
19211325Warning messages are not collected in this variable. You can,
19221326however, set up a routine to process warnings by setting C<$SIG{__WARN__}>
19231327as described below.
19241328
19251329=end original
19261330
19271331警告メッセージはこの変数に入りません。
19281332しかし、後述する C<$SIG{__WARN__}> にセットすることで
19291333警告を処理するルーチンを設定できます。
19301334
19311335=begin original
19321336
19331337Also see L<Error Indicators>.
19341338
19351339=end original
19361340
19371341L<Error Indicators> も参照して下さい。
19381342
19391343=item $PROCESS_ID
19401344
19411345=item $PID
19421346
19431347=item $$
1944X<$$> X<$PID> X<$PROCESS_ID>
19451348
19461349=begin original
19471350
19481351The process number of the Perl running this script. You should
19491352consider this variable read-only, although it will be altered
19501353across fork() calls. (Mnemonic: same as shells.)
19511354
19521355=end original
19531356
19541357スクリプトを実行している Perl のプロセス番号です。
19551358この変数は read-only と考えるべきですが、
19561359fork() 呼び出しによって値は変わります。
19571360(記憶法: シェルと同じ。)
19581361
1959=begin original
1960
1961Note for Linux users: on Linux, the C functions C<getpid()> and
1962C<getppid()> return different values from different threads. In order to
1963be portable, this behavior is not reflected by C<$$>, whose value remains
1964consistent across threads. If you want to call the underlying C<getpid()>,
1965you may use the CPAN module C<Linux::Pid>.
1966
1967=end original
1968
1969Linux ユーザーへの注意: Linux では、C 関数 C<getpid()> と C<getppid()> は
1970スレッドが異なると異なった値を返します。
1971移植性のために、この振る舞いは C<$$> には反映されず、この値はスレッド間で
1972一貫しています。
1973もし内在する C<getpid()> を呼び出したい場合は、CPAN モジュール
1974C<Linux::Pid> が使えます。
1975
19761362=item $REAL_USER_ID
19771363
19781364=item $UID
19791365
19801366=item $<
1981X<< $< >> X<$UID> X<$REAL_USER_ID>
19821367
19831368=begin original
19841369
19851370The real uid of this process. (Mnemonic: it's the uid you came I<from>,
1986if you're running setuid.) You can change both the real uid and
1371if you're running setuid.)
1987the effective uid at the same time by using POSIX::setuid(). Since
1988changes to $< require a system call, check $! after a change attempt to
1989detect any possible errors.
19901372
19911373=end original
19921374
19931375本プロセスの実 uid を示します。
19941376(記憶法: setuid で実行中であれば、そこ「から」来た uid です。)
1995POSIX::setuid() を使って、実効 UID と実 UID を同時に変更できます。
1996$> を変更にはシステムコールが必要なので、起こりうるエラーを検出するために
1997$! のチェックが必要です。
19981377
19991378=item $EFFECTIVE_USER_ID
20001379
20011380=item $EUID
20021381
20031382=item $>
2004X<< $> >> X<$EUID> X<$EFFECTIVE_USER_ID>
20051383
20061384=begin original
20071385
20081386The effective uid of this process. Example:
20091387
20101388=end original
20111389
20121390本プロセスの実効 uid を示します。
20131391例:
20141392
20151393 $< = $>; # set real to effective uid
20161394 ($<,$>) = ($>,$<); # swap real and effective uid
20171395
20181396=begin original
20191397
2020You can change both the effective uid and the real uid at the same
2021time by using POSIX::setuid(). Changes to $> require a check to $!
2022to detect any possible errors after an attempted change.
2023
2024=end original
2025
2026POSIX::setuid() を使って、実効 UID と実 UID を同時に変更できます。
2027$> を変更した場合は、変更時に起こりうるエラーを検出するために $! の
2028チェックが必要です。
2029
2030=begin original
2031
20321398(Mnemonic: it's the uid you went I<to>, if you're running setuid.)
20331399C<< $< >> and C<< $> >> can be swapped only on machines
20341400supporting setreuid().
20351401
20361402=end original
20371403
20381404(記憶法: setuid で実行中であれば、そこ「へ」行く uidです。)
20391405C<< $< >> と C<< $> >> の交換は、setreuid() をサポートしている
20401406マシンでのみ可能です。
20411407
20421408=item $REAL_GROUP_ID
20431409
20441410=item $GID
20451411
20461412=item $(
2047X<$(> X<$GID> X<$REAL_GROUP_ID>
20481413
20491414=begin original
20501415
20511416The real gid of this process. If you are on a machine that supports
20521417membership in multiple groups simultaneously, gives a space separated
20531418list of groups you are in. The first number is the one returned by
20541419getgid(), and the subsequent ones by getgroups(), one of which may be
20551420the same as the first number.
20561421
20571422=end original
20581423
2059本プロセスの実 gid を示します。
1424本プロセスの実 gid を示します。 同時に複数のグループに
2060同時に複数のグループに所属できるマシンでは、所属するグループをスペースで
1425所属できるマシンでは、所属するグループをスペースで
20611426区切ったリストが得られます。
20621427最初の数値は、getgid() で返されるものです。
20631428その後に getgroups() が返す値が続き、その中の 1 つは、
20641429最初の値と同じかもしれません。
20651430
20661431=begin original
20671432
20681433However, a value assigned to C<$(> must be a single number used to
20691434set the real gid. So the value given by C<$(> should I<not> be assigned
2070back to C<$(> without being forced numeric, such as by adding zero. Note
1435back to C<$(> without being forced numeric, such as by adding zero.
2071that this is different to the effective gid (C<$)>) which does take a
2072list.
20731436
20741437=end original
20751438
20761439しかし、C<$(> に代入された値は実際の gid に設定された値の
20771440一つでなければなりません。
20781441従って、 C<$(> で与えられた値はゼロを足すことによって
20791442数値化することなく C<$(> に書き戻すべきではありません。
2080これはリストが得られる実行 GID (C<$)>) とは違うことに注意してください。
20811443
20821444=begin original
20831445
2084You can change both the real gid and the effective gid at the same
2085time by using POSIX::setgid(). Changes to $( require a check to $!
2086to detect any possible errors after an attempted change.
2087
2088=end original
2089
2090POSIX::setgid() を使って、実 GID と実効 GID の両方を同時に変更できます。
2091$( を変更した場合は、変更しようとしたときに起こりうるエラーを検出するために
2092$! をチェックする必要があります。
2093
2094=begin original
2095
20961446(Mnemonic: parentheses are used to I<group> things. The real gid is the
20971447group you I<left>, if you're running setgid.)
20981448
20991449=end original
21001450
21011451(記憶法: 括弧は、I<グループ化>に使われます。
21021452setgid で実行中であれば、実 gid は I<left> した、
21031453つまり離れたグループです。)
21041454
21051455=item $EFFECTIVE_GROUP_ID
21061456
21071457=item $EGID
21081458
21091459=item $)
2110X<$)> X<$EGID> X<$EFFECTIVE_GROUP_ID>
21111460
21121461=begin original
21131462
21141463The effective gid of this process. If you are on a machine that
21151464supports membership in multiple groups simultaneously, gives a space
21161465separated list of groups you are in. The first number is the one
21171466returned by getegid(), and the subsequent ones by getgroups(), one of
21181467which may be the same as the first number.
21191468
21201469=end original
21211470
21221471本プロセスの実効 gid を示します。
21231472同時に複数のグループに所属できるマシンでは、
21241473所属するグループをスペースで区切ったリストが得られます。
21251474最初の数値は、getegid() で返されるものです。
21261475その後に getgroups()が返す値が続き、その中の 1 つは、
21271476最初の値と同じかもしれません。
21281477
21291478=begin original
21301479
21311480Similarly, a value assigned to C<$)> must also be a space-separated
21321481list of numbers. The first number sets the effective gid, and
21331482the rest (if any) are passed to setgroups(). To get the effect of an
21341483empty list for setgroups(), just repeat the new effective gid; that is,
21351484to force an effective gid of 5 and an effectively empty setgroups()
21361485list, say C< $) = "5 5" >.
21371486
21381487=end original
21391488
21401489同様に、C<$)> へ代入する値はスペースで区切られた数値の
21411490リストでなければなりません。
21421491最初の数値は実効 gid を設定し、残りの数値は(もしあれば) setgroups() に
21431492渡されます。
21441493setgroups() に空リストを渡したい場合は、単に新しい実効 gid を
21451494繰り返してください。
21461495つまり、実効 gid を 5 にして、setgroups() に空リストを渡したい場合は、
21471496C< $) = "5 5" > としてください。
21481497
21491498=begin original
21501499
2151You can change both the effective gid and the real gid at the same
2152time by using POSIX::setgid() (use only a single numeric argument).
2153Changes to $) require a check to $! to detect any possible errors
2154after an attempted change.
2155
2156=end original
2157
2158POSIX::setgid() を使って、実効 GID と実 GID を同時に変更できます。
2159(1 つの数値引数だけが使えます)。
2160$) を変更した場合は、変更時に起こりうるエラーを検出するために $! の
2161チェックが必要です。
2162
2163=begin original
2164
21651500(Mnemonic: parentheses are used to I<group> things. The effective gid
21661501is the group that's I<right> for you, if you're running setgid.)
21671502
21681503=end original
21691504
21701505(記憶法: 括弧は、I<グループ化>に使われます。
21711506setgid で実行中であれば、実効 gid は right な、つまり正しいグループです。)
21721507
21731508=begin original
21741509
21751510C<< $< >>, C<< $> >>, C<$(> and C<$)> can be set only on
21761511machines that support the corresponding I<set[re][ug]id()> routine. C<$(>
21771512and C<$)> can be swapped only on machines supporting setregid().
21781513
21791514=end original
21801515
21811516C<< $< >>, C<< $> >>, C<$(>, C<$)> は、実行するマシンで、
21821517対応する I<set[re][ug]id()> ルーティンがサポートされているときにのみ
21831518設定可能です。
21841519C<$(> と C<$)> の交換は、
21851520setregid() がサポートされているマシンでのみ可能です。
21861521
21871522=item $PROGRAM_NAME
21881523
21891524=item $0
2190X<$0> X<$PROGRAM_NAME>
21911525
21921526=begin original
21931527
2194Contains the name of the program being executed.
1528Contains the name of the program being executed. On some operating
1529systems assigning to C<$0> modifies the argument area that the B<ps>
1530program sees. This is more useful as a way of indicating the current
1531program state than it is for hiding the program you're running.
1532(Mnemonic: same as B<sh> and B<ksh>.)
21951533
21961534=end original
21971535
21981536実行されているプログラムの名前を示します。
2199
2200=begin original
2201
2202On some (read: not all) operating systems assigning to C<$0> modifies
2203the argument area that the C<ps> program sees. On some platforms you
2204may have to use special C<ps> options or a different C<ps> to see the
2205changes. Modifying the $0 is more useful as a way of indicating the
2206current program state than it is for hiding the program you're
2207running. (Mnemonic: same as B<sh> and B<ksh>.)
2208
2209=end original
2210
22111537C<$0> に代入を行なうことで B<ps>) プログラムが覗く、
2212引数エリアを修正できるシステムもあります(全てではありません)
1538引数エリアを修正できるシステムもあります。
2213$0 の修正は、実行しているプログラムを隠すよりは、
1539実行しているプログラムを隠すよりは、
22141540実行中のプログラムの状態を表示するときに、使うとよいでしょう。
22151541(記憶法: B<sh> や B<ksh> と同じ。)
22161542
22171543=begin original
22181544
2219Note that there are platform specific limitations on the maximum
2220length of C<$0>. In the most extreme case it may be limited to the
2221space occupied by the original C<$0>.
2222
2223=end original
2224
2225C<$0> の最大長にはプラットフォーム固有の制限があることに注意してください。
2226最も極端な場合では、元の C<$0> で占められているサイズに制限されます。
2227
2228=begin original
2229
2230In some platforms there may be arbitrary amount of padding, for
2231example space characters, after the modified name as shown by C<ps>.
2232In some platforms this padding may extend all the way to the original
2233length of the argument area, no matter what you do (this is the case
2234for example with Linux 2.2).
2235
2236=end original
2237
2238プラットフォームによっては、任意の量のパッディングがある場合があります;
2239例えば、C<ps> で見られる修正された名前の後の空白文字です。
2240プラットフォームによっては、このパッディングは、あなたが何をしたかに
2241関わらず、元の引数のエリア全体に拡張されるものもあります
2242(例えば、これは Linux 2.2 の場合です)。
2243
2244=begin original
2245
22461545Note for BSD users: setting C<$0> does not completely remove "perl"
2247from the ps(1) output. For example, setting C<$0> to C<"foobar"> may
1546from the ps(1) output. For example, setting C<$0> to C<"foobar"> will
2248result in C<"perl: foobar (perl)"> (whether both the C<"perl: "> prefix
1547result in C<"perl: foobar (perl)">. This is an operating system
2249and the " (perl)" suffix are shown depends on your exact BSD variant
1548feature.
2250and version). This is an operating system feature, Perl cannot help it.
22511549
22521550=end original
22531551
22541552BSD ユーザーへの注意: C<$0> に値をセットしても、ps(1) の出力から
22551553完全に "perl" の文字列は取り除かれません。
22561554例えば、C<$0> に C<"foobar"> と設定すると、C<"perl: foobar (perl)"> という
2257結果になります
1555結果になります。これはオペレーティングシステムの機能です。
2258(C<"perl: "> 接頭辞と" (perl)" 接尾辞が表示されるかどうかは 、正確な
2259BSD の種類とバージョンに依存します)。
2260これはオペレーティングシステムの機能で、Perl は何もできません。
22611556
2262=begin original
2263
2264In multithreaded scripts Perl coordinates the threads so that any
2265thread may modify its copy of the C<$0> and the change becomes visible
2266to ps(1) (assuming the operating system plays along). Note that
2267the view of C<$0> the other threads have will not change since they
2268have their own copies of it.
2269
2270=end original
2271
2272マルチスレッドスクリプトでは、どのスレッドも自身の C<$0> のコピーを
2273変更できて、その変更が(OS が対応しているとして) ps(1) で見えるように、
2274Perl がスレッドを調整します。
2275他のスレッドが持っている C<$0> の見え方は(各自が自身のコピーを
2276持っているので)変わらないことに注意してください。
2277
2278=begin original
2279
2280If the program has been given to perl via the switches C<-e> or C<-E>,
2281C<$0> will contain the string C<"-e">.
2282
2283=end original
2284
2285プログラムが perl に C<-e> または C<-E> オプション経由で与えられた場合、
2286C<$0> には文字列 C<"-e"> を含みます。
2287
22881557=item $[
2289X<$[>
22901558
22911559=begin original
22921560
22931561The index of the first element in an array, and of the first character
22941562in a substring. Default is 0, but you could theoretically set it
22951563to 1 to make Perl behave more like B<awk> (or Fortran) when
22961564subscripting and when evaluating the index() and substr() functions.
22971565(Mnemonic: [ begins subscripts.)
22981566
22991567=end original
23001568
23011569配列の最初の要素や、文字列の最初の文字のインデックスを
23021570示します。
23031571デフォルトは 0 ですが、理論的には、index() 関数や
23041572substr() 関数を評価するときに、Perl の動作をより B<awk>
23051573(や Fortran) に近づけるため、1 に設定することもできます。
23061574(記憶法: [ は添え字付けの始め。)
23071575
23081576=begin original
23091577
23101578As of release 5 of Perl, assignment to C<$[> is treated as a compiler
23111579directive, and cannot influence the behavior of any other file.
2312(That's why you can only assign compile-time constants to it.)
23131580Its use is highly discouraged.
23141581
23151582=end original
23161583
2317Perl 5 からは C<$[> への代入は、コンパイラ指示子として扱われ、
1584Perl 5 からは C<$[> への代入は、コンパイラへのディレクティブとして扱われ、
23181585他のファイルの動作に影響を与えることがなくなりました。
2319(これが、コンパイル時定数しか代入できない理由です。)
23201586この変数はできるだけ使わないようにしてください。
23211587
2322=begin original
2323
2324Note that, unlike other compile-time directives (such as L<strict>),
2325assignment to C<$[> can be seen from outer lexical scopes in the same file.
2326However, you can use local() on it to strictly bind its value to a
2327lexical block.
2328
2329=end original
2330
2331(L<strict> のような) その他のコンパイル時指示子と違って、C<$[> への代入は、
2332同じファイルのより外側のレキシカルスコープからも見えることに注意してください。
2333但し、これに local() を使うことでこの値をレキシカルブロック内に束縛できます。
2334
23351588=item $]
2336X<$]>
23371589
23381590=begin original
23391591
23401592The version + patchlevel / 1000 of the Perl interpreter. This variable
23411593can be used to determine whether the Perl interpreter executing a
23421594script is in the right range of versions. (Mnemonic: Is this version
23431595of perl in the right bracket?) Example:
23441596
23451597=end original
23461598
23471599Perl インタプリタの version + patchlevel / 1000 が返されます。
23481600スクリプトの最初で、そのスクリプトを実行しているインタプリタのバージョンが
23491601適切な範囲内にあるかを調べる、といったことができます。
2350(記憶法: Perl のバージョンは、正しい範囲 (right bracket) にあるか。)
1602(記憶法: Perl のバージョンは、正しい範囲 (right
2351例:
1603bracket) にあるか。) 例:
23521604
23531605 warn "No checksumming!\n" if $] < 3.019;
23541606
23551607=begin original
23561608
23571609See also the documentation of C<use VERSION> and C<require VERSION>
23581610for a convenient way to fail if the running Perl interpreter is too old.
23591611
23601612=end original
23611613
23621614実行する Perl インタプリタが古すぎる場合に終了する便利な方法に
23631615ついては C<use VERSION> と C<require VERSION> のドキュメントも
23641616参照して下さい。
23651617
23661618=begin original
23671619
2368The floating point representation can sometimes lead to inaccurate
1620The use of this variable is deprecated. The floating point representation
2369numeric comparisons. See C<$^V> for a more modern representation of
1621can sometimes lead to inaccurate numeric comparisons. See C<$^V> for a
2370the Perl version that allows accurate string comparisons.
1622more modern representation of the Perl version that allows accurate string
1623comparisons.
23711624
23721625=end original
23731626
2374浮動小点表現数値比較が不正確にることがあります
1627この変数は使わいようにしてください
1628浮動小数点表現は数値比較が不正確に成ることがあります。
23751629文字列比較が使える新しい Perl バージョンの表現方法である C<$^V> を
23761630参照して下さい。
23771631
23781632=item $COMPILING
23791633
23801634=item $^C
2381X<$^C> X<$COMPILING>
23821635
23831636=begin original
23841637
23851638The current value of the flag associated with the B<-c> switch.
23861639Mainly of use with B<-MO=...> to allow code to alter its behavior
23871640when being compiled, such as for example to AUTOLOAD at compile
2388time rather than normal, deferred loading. Setting
1641time rather than normal, deferred loading. See L<perlcc>. Setting
23891642C<$^C = 1> is similar to calling C<B::minus_c>.
23901643
23911644=end original
23921645
23931646B<-c> スイッチに関連付けられた現在の値です。
23941647主に B<-MO=...> と共に用いられ、例えば AUTOLOAD を通常の遅延ロードでは
23951648なくコンパイル時に実行するといった、コンパイル時の振る舞いを
2396変えるために用います。
1649変えるために用います。L<perlcc> を参照して下さい。
23971650C<$^C = 1> に設定することは C<B::minus_c> を呼び出すのと似ています。
23981651
23991652=item $DEBUGGING
24001653
24011654=item $^D
2402X<$^D> X<$DEBUGGING>
24031655
24041656=begin original
24051657
24061658The current value of the debugging flags. (Mnemonic: value of B<-D>
2407switch.) May be read or set. Like its command-line equivalent, you can use
1659switch.)
2408numeric or symbolic values, eg C<$^D = 10> or C<$^D = "st">.
24091660
24101661=end original
24111662
24121663デバッグフラグの現在の値を示します。
24131664(記憶法: B<-D> スイッチの値。)
2414読み書き可能です。
2415コマンドラインによる等価な機能と同様に、数値とシンボル値が使えます
2416(例: C<$^D = 10> または C<$^D = "st">)。
24171665
2418=item ${^RE_DEBUG_FLAGS}
2419
2420=begin original
2421
2422The current value of the regex debugging flags. Set to 0 for no debug output
2423even when the re 'debug' module is loaded. See L<re> for details.
2424
2425=end original
2426
2427正規表現デバッグフラグの現在の値です。
24280 をセットすると、re 'debug' モジュールが読み込まれていても
2429デバッグ出力を行いません。
2430詳細については L<re> を参照してください。
2431
2432=item ${^RE_TRIE_MAXBUF}
2433
2434=begin original
2435
2436Controls how certain regex optimisations are applied and how much memory they
2437utilize. This value by default is 65536 which corresponds to a 512kB temporary
2438cache. Set this to a higher value to trade memory for speed when matching
2439large alternations. Set it to a lower value if you want the optimisations to
2440be as conservative of memory as possible but still occur, and set it to a
2441negative value to prevent the optimisation and conserve the most memory.
2442Under normal situations this variable should be of no interest to you.
2443
2444=end original
2445
2446どれくらい正規表現の最適化を行い、どれくらいのメモリを利用するかを
2447制御します。
2448デフォルトではこの値は 65536 で、512kB の一時キャッシュに相当します。
2449この値を大きくすると、大きなものとマッチングするときに速度を重視して
2450多くのメモリを使います。
2451もしできるだけ保守的なメモリ消費をするけれども使うこともある、というように
2452最適化したい場合は小さい値を設定します; 負の値を設定すると最適化は行わず、
2453最大限メモリを節約します。
2454通常の状況では、この変数はあなたの興味を引くものではないでしょう。
2455
24561666=item $SYSTEM_FD_MAX
24571667
24581668=item $^F
2459X<$^F> X<$SYSTEM_FD_MAX>
24601669
24611670=begin original
24621671
24631672The maximum system file descriptor, ordinarily 2. System file
24641673descriptors are passed to exec()ed processes, while higher file
24651674descriptors are not. Also, during an open(), system file descriptors are
24661675preserved even if the open() fails. (Ordinary file descriptors are
24671676closed before the open() is attempted.) The close-on-exec
24681677status of a file descriptor will be decided according to the value of
24691678C<$^F> when the corresponding file, pipe, or socket was opened, not the
24701679time of the exec().
24711680
24721681=end original
24731682
2474システムが使用するファイル記述子の最大値を示し、通常は 2 です。
1683システムが使用するファイル記述子の最大値を示し、
1684通常は 2 です。
24751685システムファイル記述子は、exec() されたプロセスに渡されますが、
24761686それ以降のファイル記述子は渡されません。
24771687また、open() の実行中は、システムファイル記述子は、
24781688たとえ open() が失敗しても、保存されます。
24791689(通常のファイル記述子は、open() が実行される前にクローズされます。)
24801690ファイル記述子の close-on-exec のステータスは、exec() 時ではなく、
24811691対応するファイル、パイプソケットの open 時の C<$^F> の値によって
24821692決められます。
24831693
24841694=item $^H
24851695
24861696=begin original
24871697
24881698WARNING: This variable is strictly for internal use only. Its availability,
24891699behavior, and contents are subject to change without notice.
24901700
24911701=end original
24921702
24931703警告: この変数は厳密に内部使用に限定されます。
24941704その可用性、挙動、内容は告知なく変更される可能性があります。
24951705
24961706=begin original
24971707
24981708This variable contains compile-time hints for the Perl interpreter. At the
24991709end of compilation of a BLOCK the value of this variable is restored to the
25001710value when the interpreter started to compile the BLOCK.
25011711
25021712=end original
25031713
25041714この変数には Perl インタプリタのコンパイル時のヒントが入ります。
25051715BLOCK のコンパイル終了時に、この変数の値は
25061716インタプリタが BLOCK のコンパイルを開始した時の値に戻されます。
25071717
25081718=begin original
25091719
25101720When perl begins to parse any block construct that provides a lexical scope
25111721(e.g., eval body, required file, subroutine body, loop body, or conditional
25121722block), the existing value of $^H is saved, but its value is left unchanged.
25131723When the compilation of the block is completed, it regains the saved value.
25141724Between the points where its value is saved and restored, code that
25151725executes within BEGIN blocks is free to change the value of $^H.
25161726
25171727=end original
25181728
25191729Perl がレキシカルスコープを持つブロック構造(eval の中身、required された
25201730ファイル、サブルーチンの中身、loop の中身、条件付きブロック)の
25211731パーズを開始するとき、現在の $^H の値は保存されますが、
25221732値は変更されません。
25231733ブロックのコンパイルが終わると、保存された値が戻されます。
25241734値の保存と回復の間の地点で、
25251735BEGIN ブロックの中で実行されるコードは自由に
25261736$^H の値を変更できます。
25271737
25281738=begin original
25291739
25301740This behavior provides the semantic of lexical scoping, and is used in,
25311741for instance, the C<use strict> pragma.
25321742
25331743=end original
25341744
25351745この振る舞いはレキシカルスコープを持ち、その中で使えます。
25361746例としては C<use strict> があります。
25371747
25381748=begin original
25391749
25401750The contents should be an integer; different bits of it are used for
25411751different pragmatic flags. Here's an example:
25421752
25431753=end original
25441754
25451755内容は整数であるべきです。
25461756ビット毎に異なるプラグマフラグとして使われます。以下は例です:
25471757
25481758 sub add_100 { $^H |= 0x100 }
25491759
25501760 sub foo {
25511761 BEGIN { add_100() }
25521762 bar->baz($boon);
25531763 }
25541764
25551765=begin original
25561766
25571767Consider what happens during execution of the BEGIN block. At this point
25581768the BEGIN block has already been compiled, but the body of foo() is still
25591769being compiled. The new value of $^H will therefore be visible only while
25601770the body of foo() is being compiled.
25611771
25621772=end original
25631773
25641774BEGIN ブロックの実行中に起こることを考えてみます。
25651775この時点で BEGIN ブロックは既にコンパイルされていますが、
25661776foo() の中身はまだコンパイル中です。
25671777従って $^H の新しい値は foo() の中身がコンパイル中にのみ
25681778見ることが出来ます。
25691779
25701780=begin original
25711781
25721782Substitution of the above BEGIN block with:
25731783
25741784=end original
25751785
25761786上記の BEGIN ブロックを以下のように変更すると:
25771787
25781788 BEGIN { require strict; strict->import('vars') }
25791789
25801790=begin original
25811791
25821792demonstrates how C<use strict 'vars'> is implemented. Here's a conditional
25831793version of the same lexical pragma:
25841794
25851795=end original
25861796
25871797どのように C<use strict 'vars'> が実装されているかがわかります。
25881798以下は同じレキシカルプラグマの条件付き版です:
25891799
25901800 BEGIN { require strict; strict->import('vars') if $condition }
25911801
25921802=item %^H
25931803
25941804=begin original
25951805
1806WARNING: This variable is strictly for internal use only. Its availability,
1807behavior, and contents are subject to change without notice.
1808
1809=end original
1810
1811警告: この変数は厳密に内部使用に限定されます。
1812その可用性、挙動、内容は告知なく変更される可能性があります。
1813
1814=begin original
1815
25961816The %^H hash provides the same scoping semantic as $^H. This makes it
2597useful for implementation of lexically scoped pragmas. See L<perlpragma>.
1817useful for implementation of lexically scoped pragmas.
25981818
25991819=end original
26001820
26011821%^H ハッシュは $^H と同じスコープを持ちます。
26021822これはレキシカルスコープを持つプラグマを実装するのに便利です。
2603L<perlpragma> を参照してください。
26041823
26051824=item $INPLACE_EDIT
26061825
26071826=item $^I
2608X<$^I> X<$INPLACE_EDIT>
26091827
26101828=begin original
26111829
26121830The current value of the inplace-edit extension. Use C<undef> to disable
26131831inplace editing. (Mnemonic: value of B<-i> switch.)
26141832
26151833=end original
26161834
26171835置き換え編集の拡張子の値を示します。
26181836置き換え編集を禁止するためには、C<undef> を設定します。
26191837(記憶法: B<-i> スイッチの値。)
26201838
26211839=item $^M
2622X<$^M>
26231840
26241841=begin original
26251842
26261843By default, running out of memory is an untrappable, fatal error.
26271844However, if suitably built, Perl can use the contents of C<$^M>
26281845as an emergency memory pool after die()ing. Suppose that your Perl
2629were compiled with C<-DPERL_EMERGENCY_SBRK> and used Perl's malloc.
1846were compiled with -DPERL_EMERGENCY_SBRK and used Perl's malloc.
26301847Then
26311848
26321849=end original
26331850
26341851デフォルトでは、メモリ不足はトラップできない致命的エラーとなります。
26351852しかし、もし適切に構築されていれば、Perl は C<$^M> の中身を
26361853die() した後の緊急用メモリとして使えます。
2637Perl が C<-DPERL_EMERGENCY_SBRK> 付きでコンパイルされ、
1854Perl が -DPERL_EMERGENCY_SBRK 付きでコンパイルされ、
26381855Perl の malloc を使うと仮定します。そして、
26391856
26401857 $^M = 'a' x (1 << 16);
26411858
26421859=begin original
26431860
26441861would allocate a 64K buffer for use in an emergency. See the
26451862F<INSTALL> file in the Perl distribution for information on how to
2646add custom C compilation flags when compiling perl. To discourage casual
1863enable this option. To discourage casual use of this advanced
2647use of this advanced feature, there is no L<English|English> long name for
1864feature, there is no L<English|English> long name for this variable.
2648this variable.
26491865
26501866=end original
26511867
26521868とすると緊急用の 64K のバッファを割り当てます。
2653perl をコンパイルするときに独自 C コパイルフラグ追加する
1869オプションを有効にする方法についての情報は
2654方法についての情報は、Perl 配布パッケージに含まれている
1870Perl 配布パッケージに含まれている F<INSTALL> ファイルを参照して下さい。
2655F<INSTALL> ファイルを参照して下さい。
26561871この拡張機能を気軽に使えないようにするために、
26571872この変数には L<English|English> の長い名前はありません。
26581873
26591874=item $OSNAME
26601875
26611876=item $^O
2662X<$^O> X<$OSNAME>
26631877
26641878=begin original
26651879
26661880The name of the operating system under which this copy of Perl was
26671881built, as determined during the configuration process. The value
26681882is identical to C<$Config{'osname'}>. See also L<Config> and the
26691883B<-V> command-line switch documented in L<perlrun>.
26701884
26711885=end original
26721886
26731887この Perl が構築されたオペレーティングシステムの名前です。
26741888これは設定プロセス中に決定されます。
26751889この値は C<$Config{'osname'}> と同じです。
26761890L<Config> と、L<perlrun> でドキュメント化されている
26771891B<-V> コマンドラインスイッチも参照して下さい。
26781892
2679=begin original
2680
2681In Windows platforms, $^O is not very helpful: since it is always
2682C<MSWin32>, it doesn't tell the difference between
268395/98/ME/NT/2000/XP/CE/.NET. Use Win32::GetOSName() or
2684Win32::GetOSVersion() (see L<Win32> and L<perlport>) to distinguish
2685between the variants.
2686
2687=end original
2688
2689Windows プラットフォームでは、$^O はあまり役に立ちません: これは常に
2690C<MSWin32> となり、95/98/ME/NT/2000/XP/CE/.NET の違いを示していないからです。
2691これらを区別するためには、Win32::GetOSName() や Win32::GetOSVersion() を
2692使ってください (L<Win32> と L<perlport> を参照してください)。
2693
2694=item ${^OPEN}
2695
2696=begin original
2697
2698An internal variable used by PerlIO. A string in two parts, separated
2699by a C<\0> byte, the first part describes the input layers, the second
2700part describes the output layers.
2701
2702=end original
2703
2704PerlIO で使われる内部変数です。
2705文字列は C<\0> で分割された二つの部分からなり、前半は入力層を、
2706後半は出力層を示します。
2707
27081893=item $PERLDB
27091894
27101895=item $^P
2711X<$^P> X<$PERLDB>
27121896
27131897=begin original
27141898
27151899The internal variable for debugging support. The meanings of the
27161900various bits are subject to change, but currently indicate:
27171901
27181902=end original
27191903
27201904デバッグ機能のための内部変数です。
27211905それぞれのビットの意味は変わるかもしれませんが、
27221906現在のところは以下の通りです:
27231907
27241908=over 6
27251909
27261910=item 0x01
27271911
27281912=begin original
27291913
27301914Debug subroutine enter/exit.
27311915
27321916=end original
27331917
27341918サブルーチンの出入りをデバッグします。
27351919
27361920=item 0x02
27371921
27381922=begin original
27391923
2740Line-by-line debugging. Causes DB::DB() subroutine to be called for each
1924Line-by-line debugging.
2741statement executed. Also causes saving source code lines (like 0x400).
27421925
27431926=end original
27441927
27451928行毎にデバッグします。
2746各行を実行する毎に DB::DB() サブルーチンを呼び出します。
2747さらに、(0x400 のように) ソースコードを保存します。
27481929
27491930=item 0x04
27501931
27511932=begin original
27521933
27531934Switch off optimizations.
27541935
27551936=end original
27561937
27571938最適化を行いません。
27581939
27591940=item 0x08
27601941
27611942=begin original
27621943
27631944Preserve more data for future interactive inspections.
27641945
27651946=end original
27661947
27671948将来の対話的な検査のためにより多くのデータを保存します。
27681949
27691950=item 0x10
27701951
27711952=begin original
27721953
27731954Keep info about source lines on which a subroutine is defined.
27741955
27751956=end original
27761957
27771958サブルーチンが定義されたソース行に関する情報を保持します。
27781959
27791960=item 0x20
27801961
27811962=begin original
27821963
27831964Start with single-step on.
27841965
27851966=end original
27861967
27871968シングルステップ実行で開始します。
27881969
27891970=item 0x40
27901971
27911972=begin original
27921973
27931974Use subroutine address instead of name when reporting.
27941975
27951976=end original
27961977
27971978報告時にサブルーチン名でなくサブルーチンのアドレスを使います。
27981979
27991980=item 0x80
28001981
28011982=begin original
28021983
28031984Report C<goto &subroutine> as well.
28041985
28051986=end original
28061987
28071988C<goto &subroutine> も同様に報告します。
28081989
28091990=item 0x100
28101991
28111992=begin original
28121993
28131994Provide informative "file" names for evals based on the place they were compiled.
28141995
28151996=end original
28161997
28171998eval に対して、コンパイルされた位置を元にした「ファイル」名を提供します。
28181999
28192000=item 0x200
28202001
28212002=begin original
28222003
28232004Provide informative names to anonymous subroutines based on the place they
28242005were compiled.
28252006
28262007=end original
28272008
28282009無名サブルーチンに対して、
28292010コンパイルされた位置を基にした参考名を提供します。
28302011
2831=item 0x400
2832
2833=begin original
2834
2835Save source code lines into C<@{"_<$filename"}>.
2836
2837=end original
2838
2839ソースコードの行数を C<@{"_<$filename"}> に保存します。
2840
28412012=back
28422013
28432014=begin original
28442015
28452016Some bits may be relevant at compile-time only, some at
28462017run-time only. This is a new mechanism and the details may change.
2847See also L<perldebguts>.
28482018
28492019=end original
28502020
2851無名サブルーチンに対して
2021パイル時のみ有効なビットもあり実行時にのみ有効なビットもあります。
2852コンパイルさた位置を基にた参考名を提供しま
2022は新いメカニズムであり、詳細は変わるかもせん
2853See also L<perldebguts>.
28542023
28552024=item $LAST_REGEXP_CODE_RESULT
28562025
28572026=item $^R
2858X<$^R> X<$LAST_REGEXP_CODE_RESULT>
28592027
28602028=begin original
28612029
28622030The result of evaluation of the last successful C<(?{ code })>
28632031regular expression assertion (see L<perlre>). May be written to.
28642032
28652033=end original
28662034
28672035最後に成功した C<(?{ code })> 正規表現アサートの評価の結果です
28682036(L<perlre> を参照して下さい)。おそらくもっと書き足します。
28692037
28702038=item $EXCEPTIONS_BEING_CAUGHT
28712039
28722040=item $^S
2873X<$^S> X<$EXCEPTIONS_BEING_CAUGHT>
28742041
28752042=begin original
28762043
2877Current state of the interpreter.
2044Current state of the interpreter. Undefined if parsing of the current
2045module/eval is not finished (may happen in $SIG{__DIE__} and
2046$SIG{__WARN__} handlers). True if inside an eval(), otherwise false.
28782047
28792048=end original
28802049
28812050現在のインタプリタの状態を示します。
2051現在のモジュール/eval のパーズが終了していない場合は
2052未定義です(これは $SIG{__DIE__} と $SIG{__WARN__} のハンドラで
2053起こり得ます)。
2054eval() の内部では真、それ以外では偽となります。
28822055
2883=begin original
2884
2885 $^S State
2886 --------- -------------------
2887 undef Parsing module/eval
2888 true (1) Executing an eval
2889 false (0) Otherwise
2890
2891=end original
2892
2893 $^S State
2894 --------- -------------------
2895 undef モジュール/eval のパース中
2896 真 (1) eval の実行中
2897 偽 (0) その他
2898
2899=begin original
2900
2901The first state may happen in $SIG{__DIE__} and $SIG{__WARN__} handlers.
2902
2903=end original
2904
2905最初の状態は $SIG{__DIE__} と $SIG{__WARN__} のハンドラで起きる可能性が
2906あります。
2907
29082056=item $BASETIME
29092057
29102058=item $^T
2911X<$^T> X<$BASETIME>
29122059
29132060=begin original
29142061
29152062The time at which the program began running, in seconds since the
29162063epoch (beginning of 1970). The values returned by the B<-M>, B<-A>,
29172064and B<-C> filetests are based on this value.
29182065
29192066=end original
29202067
29212068プログラムを実行開始した時刻を、紀元 (1970年の始め) からの秒数で示したものです。
29222069ファイルテスト B<-M>、B<-A>、B<-C> で返される値は、この値に基づいています。
29232070
2924=item ${^TAINT}
2925
2926=begin original
2927
2928Reflects if taint mode is on or off. 1 for on (the program was run with
2929B<-T>), 0 for off, -1 when only taint warnings are enabled (i.e. with
2930B<-t> or B<-TU>). This variable is read-only.
2931
2932=end original
2933
2934汚染検査モードのオン・オフを反映します。
29351 はオン(プログラムは B<-T> 付きで実行されている)、0 はオフ、-1 は汚染
2936警告のみが有効になっている(つまり B<-t> か B<-TU>)ことを意味します。
2937この変数は読み込み専用です。
2938
2939=item ${^UNICODE}
2940
2941=begin original
2942
2943Reflects certain Unicode settings of Perl. See L<perlrun>
2944documentation for the C<-C> switch for more information about
2945the possible values. This variable is set during Perl startup
2946and is thereafter read-only.
2947
2948=end original
2949
2950Perl のいくつかの Unicode 設定を反映します。
2951設定できる値に関するさらなる情報については L<perlrun> の C<-C> オプションを
2952参照してください。
2953この変数は Perl 起動時に設定され、その後は読み込み専用です。
2954
2955=item ${^UTF8CACHE}
2956
2957=begin original
2958
2959This variable controls the state of the internal UTF-8 offset caching code.
29601 for on (the default), 0 for off, -1 to debug the caching code by checking
2961all its results against linear scans, and panicking on any discrepancy.
2962
2963=end original
2964
2965この変数は内部 UTF-8 オフセットキャッシュコードの状態を制御します。
29661 はオン(デフォルト)、0 はオフ、-1 は全ての結果を線形走査と比較して、
2967矛盾があれば異常終了する、という形でキャッシュコードをデバッグします。
2968
2969=item ${^UTF8LOCALE}
2970
2971=begin original
2972
2973This variable indicates whether an UTF-8 locale was detected by perl at
2974startup. This information is used by perl when it's in
2975adjust-utf8ness-to-locale mode (as when run with the C<-CL> command-line
2976switch); see L<perlrun> for more info on this.
2977
2978=end original
2979
2980この変数は、起動時に perl によって UTF-8 ロケールが検出されたかどうかを
2981示します。
2982この情報は(C<-CL> コマンドラインスイッチで起動されることによって)
2983「utf8 性をロケールに合わせる」モードのときに perl によって使われます;
2984これに関するさらなる情報は L<perlrun> を参照してください。
2985
29862071=item $PERL_VERSION
29872072
29882073=item $^V
2989X<$^V> X<$PERL_VERSION>
29902074
29912075=begin original
29922076
29932077The revision, version, and subversion of the Perl interpreter, represented
2994as a C<version> object.
2078as a string composed of characters with those ordinals. Thus in Perl v5.6.0
2079it equals C<chr(5) . chr(6) . chr(0)> and will return true for
2080C<$^V eq v5.6.0>. Note that the characters in this string value can
2081potentially be in Unicode range.
29952082
29962083=end original
29972084
2998C<version> オブジェクトとして表現される revision, version, subversion
2085Perl インタプリタの revision, version, subversion
2086それぞれの序数の文字からなる文字列で表現します。
2087つまり Perl v5.6.0 では C<chr(5) . chr(6) . chr(0)> となり、
2088C<$^V eq v5.6.0> は真を返します。
2089この文字列の文字は Unicode の範囲に入るかもしれないことに注意してください。
29992090
30002091=begin original
30012092
3002This variable first appeared in perl 5.6.0; earlier versions of perl will
2093This can be used to determine whether the Perl interpreter executing a
3003see an undefined value. Before perl 5.10.0 $^V was represented as a v-string.
3004
3005=end original
3006
3007この変数は perl 5.6.0 で最初に現れました; それより前のバージョンでは
3008未定義値となります。
3009perl 5.10.0 以前では $^V は v-string 形式で表現されます。
3010
3011=begin original
3012
3013$^V can be used to determine whether the Perl interpreter executing a
30142094script is in the right range of versions. (Mnemonic: use ^V for Version
30152095Control.) Example:
30162096
30172097=end original
30182098
3019$^V はスクリプトを実行している Perl インタプリタのバージョンが
2099これはスクリプトを実行している Perl インタプリタのバージョンが
30202100正しい範囲に入っているかを調べるのに使えます。(記憶法:
30212101^V をバージョンコントロールに使います。) 例:
30222102
3023 warn "Hashes not randomized!\n" if !$^V or $^V lt v5.8.1
2103 warn "No \"our\" declarations!\n" if $^V and $^V lt v5.6.0;
30242104
30252105=begin original
30262106
3027To convert C<$^V> into its string representation use sprintf()'s
3028C<"%vd"> conversion:
3029
3030=end original
3031
3032C<$^V> を文字列表現に変換するには sprintf() の C<"%vd"> 変換を使います:
3033
3034 printf "version is v%vd\n", $^V; # Perl's version
3035
3036=begin original
3037
30382107See the documentation of C<use VERSION> and C<require VERSION>
30392108for a convenient way to fail if the running Perl interpreter is too old.
30402109
30412110=end original
30422111
30432112実行する Perl インタプリタが古すぎる場合に終了する便利な方法に
30442113ついては C<use VERSION> と C<require VERSION> のドキュメントを
30452114参照して下さい。
30462115
30472116=begin original
30482117
30492118See also C<$]> for an older representation of the Perl version.
30502119
30512120=end original
30522121
30532122Perl バージョンの古い表現については C<$]> も参照して下さい。
30542123
30552124=item $WARNING
30562125
30572126=item $^W
3058X<$^W> X<$WARNING>
30592127
30602128=begin original
30612129
30622130The current value of the warning switch, initially true if B<-w>
30632131was used, false otherwise, but directly modifiable. (Mnemonic:
30642132related to the B<-w> switch.) See also L<warnings>.
30652133
30662134=end original
30672135
30682136警告スイッチの値で、B<-w> スイッチが使われると内部的に真となり、
30692137そうでない場合は直接変更可能です。
30702138(記憶法: B<-w> スイッチに関係します。)
30712139L<warnings> も参照して下さい。
30722140
30732141=item ${^WARNING_BITS}
30742142
30752143=begin original
30762144
30772145The current set of warning checks enabled by the C<use warnings> pragma.
30782146See the documentation of C<warnings> for more details.
30792147
30802148=end original
30812149
30822150C<use warnings> プラグマで有効にされた、現在の警告チェックの集合です。
30832151詳細については C<warnings> のドキュメントを参照して下さい。
30842152
3085=item ${^WIN32_SLOPPY_STAT}
2153=item ${^WIDE_SYSTEM_CALLS}
30862154
30872155=begin original
30882156
3089If this variable is set to a true value, then stat() on Windows will
2157Global flag that enables system calls made by Perl to use wide character
3090not try to open the file. This means that the link count cannot be
2158APIs native to the system, if available. This is currently only implemented
3091determined and file attributes may be out of date if additional
2159on the Windows platform.
3092hardlinks to the file exist. On the other hand, not opening the file
3093is considerably faster, especially for files on network drives.
30942160
30952161=end original
30962162
3097この変数が真の値セットされWindows での stat() はファイル
2163Perl システムコールでシステムにネイティブなワイド文字 API
3098オープンしようとはしません
2164(も使えるなら)使うようにするグローバルフラグです
3099これは、このァイルへの追加のハドリンクが存在る場合、リンクカウントを
2165これは現在 Windows プラットムでのみ実装されていま
3100決定できませんし、ファイル属性が古いものになるかもしれないことを
3101意味します。
3102一方、ファイルを開かないので、(特にファイルがネットワークドライブにある
3103場合は)大幅に高速です。
31042166
31052167=begin original
31062168
3107This variable could be set in the F<sitecustomize.pl> file to
2169This can also be enabled from the command line using the C<-C> switch.
3108configure the local Perl installation to use "sloppy" stat() by
3109default. See L<perlrun> for more information about site
3110customization.
31112170
31122171=end original
31132172
3114デフォルト「ずさんな」stat() を使うために、の変数は、ローカル
2173これはコマンドラインC<-C> スイッチを使うことでも有効にります。
3115Perl を設定するための F<sitecustomize.pl> で設定できます。
3116サイトカスタマイズに関するさらなる情報については L<perlrun> を
3117参照してください。
31182174
3119=item $EXECUTABLE_NAME
3120
3121=item $^X
3122X<$^X> X<$EXECUTABLE_NAME>
3123
31242175=begin original
31252176
3126The name used to execute the current copy of Perl, from C's
2177The initial value is typically C<0> for compatibility with Perl versions
3127C<argv[0]> or (where supported) F</proc/self/exe>.
2178earlier than 5.6, but may be automatically set to C<1> by Perl if the system
2179provides a user-settable default (e.g., C<$ENV{LC_CTYPE}>).
31282180
31292181=end original
31302182
3131Perl バイナリ自身が実行された時の名前を C argv[0] または (対応していれば)
2183初期値は典型的には C<0> で、これは Perl バージョン 5.6 以前と
3132F</proc/self/exe> から持ってきたものです。
2184互換性ためです。
2185しかし、システムがユーザー定義可能なデフォルト(C<$ENV{LC_CTYPE}> など)を
2186提供している場合は、Perl によって自動的に C<1> にセットされることもあります。
31332187
31342188=begin original
31352189
3136Depending on the host operating system, the value of $^X may be
2190The C<bytes> pragma always overrides the effect of this flag in the current
3137a relative or absolute pathname of the perl program file, or may
2191lexical scope. See L<bytes>.
3138be the string used to invoke perl but not the pathname of the
3139perl program file. Also, most operating systems permit invoking
3140programs that are not in the PATH environment variable, so there
3141is no guarantee that the value of $^X is in PATH. For VMS, the
3142value may or may not include a version number.
31432192
31442193=end original
31452194
3146ホスト OS に依存して、$^X の値は perlログムファイル絶対パかも
2195C<bytes> プラグマは常に現在レキシカルコープでの
3147せんし、相対パスかもしれませんし、perl起動するために使われる
2196このフラグの効果を上書きします。L<bytes>参照して下さい。
3148文字列ではありますが perl プログラムファイルのパス名ではないかもしれません。
3149また、ほとんどの OS は PATH 環境変数にない位置のプログラムを起動することを
3150許しているので、$^X の値が PATH にある保証はありません。
3151VMS では、この値はバージョン番号を含む場合も含まない場合もあります。
31522197
3153=begin original
2198=item $EXECUTABLE_NAME
31542199
3155You usually can use the value of $^X to re-invoke an independent
2200=item $^X
3156copy of the same perl that is currently running, e.g.,
31572201
3158=end original
3159
3160通常は、現在実行中のものと同じ perl の独立したコピーを再起動するために
3161$^X の値を使えます; つまり:
3162
3163 @first_run = `$^X -le "print int rand 100 for 1..100"`;
3164
31652202=begin original
31662203
3167But recall that not all operating systems support forking or
2204The name that the Perl binary itself was executed as, from C's C<argv[0]>.
3168capturing of the output of commands, so this complex statement
2205This may not be a full pathname, nor even necessarily in your path.
3169may not be portable.
31702206
31712207=end original
31722208
3173しかし、全てOS fork やコマンドの出力の捕捉に対応しいるわけ
2209Perl バイナリ自身が実行された時名前を C argv[0] から持っきたものす。
3174ないの、この複雑な文移植性がないかもしれないことを忘ないでください
2210フルパスではないかもしれませんし、検索パスにないかもしません
31752211
3176=begin original
3177
3178It is not safe to use the value of $^X as a path name of a file,
3179as some operating systems that have a mandatory suffix on
3180executable files do not require use of the suffix when invoking
3181a command. To convert the value of $^X to a path name, use the
3182following statements:
3183
3184=end original
3185
3186$^X の値をファイルのパス名として使うのは安全ではありません;
3187実行ファイルに固定の接尾辞があり、コマンドの起動時には接尾辞が不要な OS も
3188あるからです。
3189$^X の値をパス名に変換するには、以下のコードを使ってください:
3190
3191 # Build up a set of file names (not command names).
3192 use Config;
3193 $this_perl = $^X;
3194 if ($^O ne 'VMS')
3195 {$this_perl .= $Config{_exe}
3196 unless $this_perl =~ m/$Config{_exe}$/i;}
3197
3198=begin original
3199
3200Because many operating systems permit anyone with read access to
3201the Perl program file to make a copy of it, patch the copy, and
3202then execute the copy, the security-conscious Perl programmer
3203should take care to invoke the installed copy of perl, not the
3204copy referenced by $^X. The following statements accomplish
3205this goal, and produce a pathname that can be invoked as a
3206command or referenced as a file.
3207
3208=end original
3209
3210多くの OS が Perl のプログラムファイルのコピーを作って、コピーに
3211パッチを当て、それを実行するための読み込み権限を全員に与えているので、
3212セキュリティ意識のある Perl プログラマは $^X で参照されているコピーではなく、
3213インストールされている perl を起動するように気をつけるべきです。
3214以下のコードはこの目的を達成し、コマンドとして起動したりファイルとして
3215参照するためのパス名を作成します。
3216
3217 use Config;
3218 $secure_perl_path = $Config{perlpath};
3219 if ($^O ne 'VMS')
3220 {$secure_perl_path .= $Config{_exe}
3221 unless $secure_perl_path =~ m/$Config{_exe}$/i;}
3222
3223=item ARGV
3224X<ARGV>
3225
3226=begin original
3227
3228The special filehandle that iterates over command-line filenames in
3229C<@ARGV>. Usually written as the null filehandle in the angle operator
3230C<< <> >>. Note that currently C<ARGV> only has its magical effect
3231within the C<< <> >> operator; elsewhere it is just a plain filehandle
3232corresponding to the last file opened by C<< <> >>. In particular,
3233passing C<\*ARGV> as a parameter to a function that expects a filehandle
3234may not cause your function to automatically read the contents of all the
3235files in C<@ARGV>.
3236
3237=end original
3238
3239C<@ARGV> にあるコマンドラインで指定されたファイル名に対して反復する
3240特殊ファイルハンドルです。
3241通常角かっこ C<< <> >> の中で空ファイルハンドルとして書かれます。
3242現在のところ、C<ARGV> は C<< <> >> 演算子の中でのみ特別な効果があることに
3243注意してください; その他の場所では、C<< <> >> で開かれた最後のファイルに
3244対応する普通のファイルハンドルです。
3245特に、ファイルハンドルを想定している関数に C<\*ARGV> を引数として渡しても、
3246関数内で C<@ARGV> にある全てのファイルの内容を自動的に読み込むことには
3247なりません。
3248
32492212=item $ARGV
3250X<$ARGV>
32512213
32522214=begin original
32532215
32542216contains the name of the current file when reading from <>.
32552217
32562218=end original
32572219
32582220<> から読込みを行なっているとき、その時点のファイル名を示します。
32592221
32602222=item @ARGV
3261X<@ARGV>
32622223
32632224=begin original
32642225
32652226The array @ARGV contains the command-line arguments intended for
32662227the script. C<$#ARGV> is generally the number of arguments minus
32672228one, because C<$ARGV[0]> is the first argument, I<not> the program's
32682229command name itself. See C<$0> for the command name.
32692230
32702231=end original
32712232
32722233配列 @ARGV は、コマンドラインからスクリプトに渡す引数が入れられます。
32732234C<$ARGV[0]> がI<プログラムのコマンド名自身ではなく>、
32742235最初の引数ですから、C<$#ARGV> は一般には、引数の個数 - 1 となります。
32752236コマンド名については、C<$0> を参照してください。
32762237
3277=item ARGVOUT
3278X<ARGVOUT>
3279
3280=begin original
3281
3282The special filehandle that points to the currently open output file
3283when doing edit-in-place processing with B<-i>. Useful when you have
3284to do a lot of inserting and don't want to keep modifying $_. See
3285L<perlrun> for the B<-i> switch.
3286
3287=end original
3288
3289B<-i> を使ってその場修正を行っているときに、現在開いている出力ファイルを
3290示す特殊ファイルハンドルです。
3291たくさんの挿入をする必要があるときに $_ を修正し続けたくない場合に
3292有用です。
3293B<-i> オプションについては L<perlrun> を参照してください。
3294
3295=item @F
3296X<@F>
3297
3298=begin original
3299
3300The array @F contains the fields of each line read in when autosplit
3301mode is turned on. See L<perlrun> for the B<-a> switch. This array
3302is package-specific, and must be declared or given a full package name
3303if not in package main when running under C<strict 'vars'>.
3304
3305=end original
3306
3307自動 split モードが有効の場合、配列 @F には読み込んだ行のフィールドを
3308含みます。
3309B<-a> オプションについては L<perlrun> を参照してください。
3310この配列はパッケージ固有であり、もし C<strict 'vars'> で実行していて
3311パッケージ main 以外の場合は完全なパッケージ名で定義したり与えたり
3312しなければなりません。
3313
33142238=item @INC
3315X<@INC>
33162239
33172240=begin original
33182241
33192242The array @INC contains the list of places that the C<do EXPR>,
33202243C<require>, or C<use> constructs look for their library files. It
33212244initially consists of the arguments to any B<-I> command-line
33222245switches, followed by the default Perl library, probably
33232246F</usr/local/lib/perl>, followed by ".", to represent the current
3324directory. ("." will not be appended if taint checks are enabled, either by
2247directory. If you need to modify this at runtime, you should use
3325C<-T> or by C<-t>.) If you need to modify this at runtime, you should use
33262248the C<use lib> pragma to get the machine-dependent library properly
33272249loaded also:
33282250
33292251=end original
33302252
33312253配列 @INC には、do EXPR、require、use によってライブラリファイルを
33322254探すときに評価する場所のリストが納められています。
33332255初期状態では、コマンドラインスイッチ B<-I> の引数と
33342256デフォルトの Perl ライブラリディレクトリ (おそらく
33352257F</usr/local/lib/perl5>) とカレントディレクトリを表わす
33362258"." を順につなげたものです。
3337(C<-T> か C<-t> よって汚染チェック有効の場合は、"." は追加されません。)
2259実行時これを変更する必要ある場合は、
3338実行時にこれを変更する必要がある場合は、マシン依存のライブラリ正しく
2260マシン依存のライブラリ正しく読み込むために C<use lib> も使うべきです:
3339読み込むために C<use lib> を使うべきです:
33402261
33412262 use lib '/mypath/libdir/';
33422263 use SomeMod;
33432264
3344=begin original
3345
3346You can also insert hooks into the file inclusion system by putting Perl
3347code directly into @INC. Those hooks may be subroutine references, array
3348references or blessed objects. See L<perlfunc/require> for details.
3349
3350=end original
3351
3352Perl のコードを直接 @INC に入れることで、ファイルインクルード機構に
3353フックを挿入できます。
3354このフックはサブルーチンリファレンス、配列リファレンス、bless された
3355オブジェクトが可能です。
3356詳細については L<perlfunc/require> を参照してください。
3357
3358=item @ARG
3359
33602265=item @_
3361X<@_> X<@ARG>
33622266
33632267=begin original
33642268
33652269Within a subroutine the array @_ contains the parameters passed to that
33662270subroutine. See L<perlsub>.
33672271
33682272=end original
33692273
33702274サブルーチンの内部では、配列 @_ はサブルーチンに渡されたパラメータです。
33712275L<perlsub> を参照して下さい。
33722276
33732277=item %INC
3374X<%INC>
33752278
33762279=begin original
33772280
33782281The hash %INC contains entries for each filename included via the
33792282C<do>, C<require>, or C<use> operators. The key is the filename
33802283you specified (with module names converted to pathnames), and the
33812284value is the location of the file found. The C<require>
33822285operator uses this hash to determine whether a particular file has
33832286already been included.
33842287
33852288=end original
33862289
33872290ハッシュ %INC は、C<do>, C<require>, C<use>演算子によって
33882291インクルードされた、個々のファイル名をエントリとして持っています。
33892292key は指定したファイル名(モジュール名はパス名に変換されます)で、
33902293value は見つかった場所となっています。
33912294C<require> 演算子は、指定されたファイル名が既に
33922295インクルードされているかを、このハッシュを使って調べます。
33932296
3394=begin original
3395
3396If the file was loaded via a hook (e.g. a subroutine reference, see
3397L<perlfunc/require> for a description of these hooks), this hook is
3398by default inserted into %INC in place of a filename. Note, however,
3399that the hook may have set the %INC entry by itself to provide some more
3400specific info.
3401
3402=end original
3403
3404ファイルがフック(つまりサブルーチンリファレンス; フックに関する
3405説明については L<perlfunc/require> を参照してください)経由で読み込まれた
3406場合、このフックはデフォルトではファイル名の代わりに %INC に挿入されます。
3407しかし、フックはさらなる特定の情報を提供するために、自身で %INC エントリを
3408セットするかもしれないことに注意してください。
3409
34102297=item %ENV
34112298
34122299=item $ENV{expr}
3413X<%ENV>
34142300
34152301=begin original
34162302
34172303The hash %ENV contains your current environment. Setting a
34182304value in C<ENV> changes the environment for any child processes
34192305you subsequently fork() off.
34202306
34212307=end original
34222308
34232309ハッシュ %ENV には、その時点の環境変数が設定されています。
34242310C<ENV> に値を設定することで、
34252311以後に fork() した子プロセスの環境変数を変更します。
34262312
34272313=item %SIG
34282314
34292315=item $SIG{expr}
3430X<%SIG>
34312316
34322317=begin original
34332318
3434The hash C<%SIG> contains signal handlers for signals. For example:
2319The hash %SIG contains signal handlers for signals. For example:
34352320
34362321=end original
34372322
3438ハッシュ C<%SIG> にはシグナルのためのシグナルハンドラが含まれています。
2323ハッシュ %SIG にはシグナルのためのシグナルハンドラが含まれています。例:
3439例えば:
34402324
34412325 sub handler { # 1st argument is signal name
34422326 my($sig) = @_;
34432327 print "Caught a SIG$sig--shutting down\n";
34442328 close(LOG);
34452329 exit(0);
34462330 }
34472331
34482332 $SIG{'INT'} = \&handler;
34492333 $SIG{'QUIT'} = \&handler;
34502334 ...
34512335 $SIG{'INT'} = 'DEFAULT'; # restore default action
34522336 $SIG{'QUIT'} = 'IGNORE'; # ignore SIGQUIT
34532337
34542338=begin original
34552339
34562340Using a value of C<'IGNORE'> usually has the effect of ignoring the
34572341signal, except for the C<CHLD> signal. See L<perlipc> for more about
34582342this special case.
34592343
34602344=end original
34612345
34622346C<'IGNORE'> という値は通常はシグナルの効果を無視するために使いますが、
34632347C<CHLD> シグナルは例外です。
34642348この特別な場合に関する詳細は L<perlipc> を参照して下さい。
34652349
34662350=begin original
34672351
34682352Here are some other examples:
34692353
3470=end original
3471
3472以下にその他の例を示します:
3473
3474=begin original
3475
34762354 $SIG{"PIPE"} = "Plumber"; # assumes main::Plumber (not recommended)
34772355 $SIG{"PIPE"} = \&Plumber; # just fine; assume current Plumber
34782356 $SIG{"PIPE"} = *Plumber; # somewhat esoteric
34792357 $SIG{"PIPE"} = Plumber(); # oops, what did Plumber() return??
34802358
34812359=end original
34822360
2361以下にその他の例を示します:
2362
34832363 $SIG{"PIPE"} = "Plumber"; # main::Plumber を仮定します(非推奨)
34842364 $SIG{"PIPE"} = \&Plumber; # 問題なし; カレントの Plumber を仮定します
34852365 $SIG{"PIPE"} = *Plumber; # 少々難解
34862366 $SIG{"PIPE"} = Plumber(); # げげ、Plumber() は何を返すの??
34872367
34882368=begin original
34892369
34902370Be sure not to use a bareword as the name of a signal handler,
34912371lest you inadvertently call it.
34922372
34932373=end original
34942374
34952375裸の単語をシグナルハンドラの名前として使わないようにしてください。
34962376不注意で呼び出すのを避けるためです。
34972377
34982378=begin original
34992379
35002380If your system has the sigaction() function then signal handlers are
3501installed using it. This means you get reliable signal handling.
2381installed using it. This means you get reliable signal handling. If
2382your system has the SA_RESTART flag it is used when signals handlers are
2383installed. This means that system calls for which restarting is supported
2384continue rather than returning when a signal arrives. If you want your
2385system calls to be interrupted by signal delivery then do something like
2386this:
35022387
35032388=end original
35042389
35052390システムに sigaction() 関数がある場合は、
35062391シグナルハンドラはこの関数を使って設定されます。
35072392これにより、信頼性のあるシグナルハンドリングが可能になります。
2393システムに SA_RESTART フラグがある場合は、
2394シグナルハンドラはこれを使います。
2395これによりこれにより再開に対応しているシステムコールは
2396シグナルが到着したときに返らずに再開します。
2397シグナルが届いたときにシステムコールを中断したい場合は
2398以下のようにしてください:
35082399
2400 use POSIX ':signal_h';
2401
2402 my $alarm = 0;
2403 sigaction SIGALRM, new POSIX::SigAction sub { $alarm = 1 }
2404 or die "Error setting SIGALRM handler: $!\n";
2405
35092406=begin original
35102407
3511The default delivery policy of signals changed in Perl 5.8.0 from
2408See L<POSIX>.
3512immediate (also known as "unsafe") to deferred, also known as
3513"safe signals". See L<perlipc> for more information.
35142409
35152410=end original
35162411
3517デフォルトのシグナル配送ポリシーは Perl 5.8.0 に即時("unsafe"として
2412L<POSIX> を参照して下さい。
3518知られます)から保留(「安全なシグナル」としても知られます)に変更されました。
3519さらなる情報については L<perlipc> を参照してください。
35202413
35212414=begin original
35222415
35232416Certain internal hooks can be also set using the %SIG hash. The
35242417routine indicated by C<$SIG{__WARN__}> is called when a warning message is
35252418about to be printed. The warning message is passed as the first
3526argument. The presence of a C<__WARN__> hook causes the ordinary printing
2419argument. The presence of a __WARN__ hook causes the ordinary printing
3527of warnings to C<STDERR> to be suppressed. You can use this to save warnings
2420of warnings to STDERR to be suppressed. You can use this to save warnings
35282421in a variable, or turn warnings into fatal errors, like this:
35292422
35302423=end original
35312424
35322425ある種の内部フックも %SIG ハッシュを使ってセットされます。
35332426警告メッセージを表示しようとするときに C<$SIG{__WARN__}> で
35342427示されたルーチンが呼び出されます。
35352428警告メッセージは最初の引数として渡されます。
3536C<__WARN__> フックがあると、通常の C<STDERR> への警告の出力は行われません。
2429__WARN__ フックがあると、通常の STDERR への警告の出力は行われません。
35372430これを使って、警告メッセージを変数にいれたり、
35382431あるいは以下のようにして警告を致命的エラーに変えたり出来ます:
35392432
35402433 local $SIG{__WARN__} = sub { die $_[0] };
35412434 eval $proggie;
35422435
35432436=begin original
35442437
3545As the C<'IGNORE'> hook is not supported by C<__WARN__>, you can
3546disable warnings using the empty subroutine:
3547
3548=end original
3549
3550C<__WARN__> では C<'IGNORE'> フックには対応していないので、空サブルーチンを
3551使って警告を無効に出来ます:
3552
3553 local $SIG{__WARN__} = sub {};
3554
3555=begin original
3556
35572438The routine indicated by C<$SIG{__DIE__}> is called when a fatal exception
35582439is about to be thrown. The error message is passed as the first
3559argument. When a C<__DIE__> hook routine returns, the exception
2440argument. When a __DIE__ hook routine returns, the exception
35602441processing continues as it would have in the absence of the hook,
3561unless the hook routine itself exits via a C<goto>, a loop exit, or a C<die()>.
2442unless the hook routine itself exits via a C<goto>, a loop exit, or a die().
35622443The C<__DIE__> handler is explicitly disabled during the call, so that you
35632444can die from a C<__DIE__> handler. Similarly for C<__WARN__>.
35642445
35652446=end original
35662447
35672448C<$SIG{__DIE__}> で示されるルーチンは
35682449致命的な例外がまさに投げられようとするときに呼び出されます。
35692450エラーメッセージは最初の引数として渡されます。
3570C<__DIE__> フックから戻ると、
2451__DIE__ フックから戻ると、
35712452例外処理はフックがなかったかのように再開されますが、
3572フックルーチン自体が C<goto>、ループ終了、C<die()> によって
2453フックルーチン自体が C<goto>、ループ終了、die() によって
35732454終了した場合を除きます。
35742455C<__DIE__> ハンドラは呼び出し中は明示的に無効になりますので、
35752456C<__DIE__> ハンドラから die できます。
35762457C<__WARN__> も同様です。
35772458
35782459=begin original
35792460
35802461Due to an implementation glitch, the C<$SIG{__DIE__}> hook is called
35812462even inside an eval(). Do not use this to rewrite a pending exception
3582in C<$@>, or as a bizarre substitute for overriding C<CORE::GLOBAL::die()>.
2463in C<$@>, or as a bizarre substitute for overriding CORE::GLOBAL::die().
35832464This strange action at a distance may be fixed in a future release
35842465so that C<$SIG{__DIE__}> is only called if your program is about
35852466to exit, as was the original intent. Any other use is deprecated.
35862467
35872468=end original
35882469
35892470実装上の不具合により、C<$SIG{__DIE__}> は eval() の中でも
35902471呼び出されます。これを、C<$@> の待っている例外を書き換えたり、
3591C<CORE::GLOBAL::die()> を上書きするのに使わないでください。
2472CORE::GLOBAL::die() を上書きするのに使わないでください。
35922473この奇妙な行動は将来のリリースで修正される予定なので、
35932474C<$SIG{__DIE__}> は当初の目的通り、
35942475プログラムが終了するときにのみ呼び出されるようになります。
35952476その他の用途は非推奨です。
35962477
35972478=begin original
35982479
35992480C<__DIE__>/C<__WARN__> handlers are very special in one respect:
36002481they may be called to report (probable) errors found by the parser.
36012482In such a case the parser may be in inconsistent state, so any
36022483attempt to evaluate Perl code from such a handler will probably
36032484result in a segfault. This means that warnings or errors that
36042485result from parsing Perl should be used with extreme caution, like
36052486this:
36062487
36072488=end original
36082489
36092490C<__DIE__> と C<__WARN__> のハンドラは一つの点で非常に特別です。
36102491パーザによってエラー(であろうもの)を報告するために呼び出されることがある
36112492ことです。
36122493このような場合、パーザは不安定な状態になっているかもしれないので、
36132494ハンドラから Perl コードを評価しようとするとセグメンテーションフォールトが
36142495発生するかもしれません。
36152496Perl のパーズ中の警告やエラーは、以下のように非常に注意して扱うべきです。
36162497
36172498 require Carp if defined $^S;
36182499 Carp::confess("Something wrong") if defined &Carp::confess;
36192500 die "Something wrong, but could not load Carp to give backtrace...
36202501 To see backtrace try starting Perl with -MCarp switch";
36212502
36222503=begin original
36232504
36242505Here the first line will load Carp I<unless> it is the parser who
36252506called the handler. The second line will print backtrace and die if
36262507Carp was available. The third line will be executed only if Carp was
36272508not available.
36282509
36292510=end original
36302511
36312512一行目は、I<パーザがハンドラを呼び出したのでなければ>
36322513Carp を読み込みます。
36332514二行目は、Carp が使えるならバックとレースを表示して die します。
36342515三行目は Carp が使えないときにのみ実行されます。
36352516
36362517=begin original
36372518
36382519See L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>, and
36392520L<warnings> for additional information.
36402521
36412522=end original
36422523
36432524追加の情報については L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>,
36442525L<warnings> を参照して下さい。
36452526
36462527=back
36472528
36482529=head2 Error Indicators
3649X<error> X<exception>
36502530
36512531(エラー指示子)
36522532
36532533=begin original
36542534
36552535The variables C<$@>, C<$!>, C<$^E>, and C<$?> contain information
36562536about different types of error conditions that may appear during
36572537execution of a Perl program. The variables are shown ordered by
36582538the "distance" between the subsystem which reported the error and
36592539the Perl process. They correspond to errors detected by the Perl
36602540interpreter, C library, operating system, or an external program,
36612541respectively.
36622542
36632543=end original
36642544
36652545変数 C<$@>, C<$!>, C<$^E>, C<$?> は Perl プログラムの実行中に
36662546発生した、異なる種類のエラー情報を保持します。
36672547変数はエラーを報告した副システムと Perl プロセスとの「距離」
36682548の順番に並んでいます。
36692549これらはそれぞれ、Perl インタプリタ、C ライブラリ、
36702550オペレーティングシステム、外部プログラムによって検出された
36712551エラーに対応しています。
36722552
36732553=begin original
36742554
36752555To illustrate the differences between these variables, consider the
36762556following Perl expression, which uses a single-quoted string:
36772557
36782558=end original
36792559
36802560これらの変数の違いを示すために、
36812561以下のようなシングルクォートを用いた Perl 式を考えます:
36822562
36832563 eval q{
3684 open my $pipe, "/cdrom/install |" or die $!;
2564 open PIPE, "/cdrom/install |";
3685 my @res = <$pipe>;
2565 @res = <PIPE>;
3686 close $pipe or die "bad pipe: $?, $!";
2566 close PIPE or die "bad pipe: $?, $!";
36872567 };
36882568
36892569=begin original
36902570
36912571After execution of this statement all 4 variables may have been set.
36922572
36932573=end original
36942574
36952575この文を実行した後、4 つの変数全てがセットされる可能性があります。
36962576
36972577=begin original
36982578
36992579C<$@> is set if the string to be C<eval>-ed did not compile (this
37002580may happen if C<open> or C<close> were imported with bad prototypes),
37012581or if Perl code executed during evaluation die()d . In these cases
37022582the value of $@ is the compile error, or the argument to C<die>
3703(which will interpolate C<$!> and C<$?>). (See also L<Fatal>,
2583(which will interpolate C<$!> and C<$?>!). (See also L<Fatal>,
37042584though.)
37052585
37062586=end original
37072587
37082588C<$@> は C<eval> された文字列がコンパイルされなかったとき
37092589(これは C<open> か C<close> が正しくない
37102590プロトタイプでインポートされたときに起こり得ます)、
37112591または評価中に実行している Perl コードが die() したときにセットされます。
37122592これらの場合には $@ の値はコンパイルエラー、または
3713C<die> への引数(これには C<$!> と C<$?> が差し挟まれます)です。
2593C<die> への引数(これには C<$!> と C<$?> が差し挟まれます!)です。
37142594(しかし、L<Fatal> も参照して下さい。)
37152595
37162596=begin original
37172597
37182598When the eval() expression above is executed, open(), C<< <PIPE> >>,
37192599and C<close> are translated to calls in the C run-time library and
37202600thence to the operating system kernel. C<$!> is set to the C library's
37212601C<errno> if one of these calls fails.
37222602
37232603=end original
37242604
37252605上記の eval() 式が実行された後、
37262606open(), C<< <PIPE> >>, C<close> は C ランタイムライブラリの呼び出しに
37272607変換され、それからオペレーティングシステムコールに変換されます。
37282608C<$!> はこれらの呼び出しのどれかが失敗したとき、
37292609C ライブラリの C<errno> の値がセットされます。
37302610
37312611=begin original
37322612
37332613Under a few operating systems, C<$^E> may contain a more verbose
37342614error indicator, such as in this case, "CDROM tray not closed."
37352615Systems that do not support extended error messages leave C<$^E>
37362616the same as C<$!>.
37372617
37382618=end original
37392619
37402620いくつかのオペレーティングシステムでは、
37412621C<$^E> により詳細なエラー指示子が入っているかもしれません。
37422622今回の場合で言えば、"CDROM tray not closed." などです。
37432623追加のエラーメッセージに対応していないシステムでは、
37442624C<$^E> は C<$!> と同じ値です。
37452625
37462626=begin original
37472627
37482628Finally, C<$?> may be set to non-0 value if the external program
37492629F</cdrom/install> fails. The upper eight bits reflect specific
37502630error conditions encountered by the program (the program's exit()
37512631value). The lower eight bits reflect mode of failure, like signal
37522632death and core dump information See wait(2) for details. In
37532633contrast to C<$!> and C<$^E>, which are set only if error condition
37542634is detected, the variable C<$?> is set on each C<wait> or pipe
37552635C<close>, overwriting the old value. This is more like C<$@>, which
37562636on every eval() is always set on failure and cleared on success.
37572637
37582638=end original
37592639
37602640最後に、C<$?> は外部プログラム F</cdrom/install> が失敗したときに
37612641非 0 にセットされるかもしれません。
37622642上位の 8 ビットはプログラムが遭遇した特定のエラー状況
37632643(プログラムの exit() の値)を反映します。
37642644下位の 8 ビットは、シグナルの死亡やコアダンプ情報と言った失敗のモードを反映します。
37652645詳細については wait(2) を参照して下さい。
37662646C<$!> と C<$^E> はエラー状況が検出されたときにのみ設定されますが、
37672647変数 C<$?> は C<wait> やパイプの C<close> の度に、前の値を上書きします。
37682648これは、C<$@> が eval() の実行毎に、エラーならセットされ、
37692649成功ならクリアされるという動作と似ています。
37702650
37712651=begin original
37722652
37732653For more details, see the individual descriptions at C<$@>, C<$!>, C<$^E>,
37742654and C<$?>.
37752655
37762656=end original
37772657
37782658より詳細については、C<$@>, C<$!>, C<$^E>, C<$?> それぞれの説明を
37792659参照して下さい。
37802660
37812661=head2 Technical Note on the Syntax of Variable Names
37822662
37832663(変数名の文法に関するテクニカルノート)
37842664
37852665=begin original
37862666
37872667Variable names in Perl can have several formats. Usually, they
37882668must begin with a letter or underscore, in which case they can be
37892669arbitrarily long (up to an internal limit of 251 characters) and
37902670may contain letters, digits, underscores, or the special sequence
37912671C<::> or C<'>. In this case, the part before the last C<::> or
37922672C<'> is taken to be a I<package qualifier>; see L<perlmod>.
37932673
37942674=end original
37952675
37962676Perl の変数名は様々な形があります。
37972677通常、変数名は英文字か下線で始まらなければならず、
37982678任意の長さ(内部制限の 251 文字まで)を取ることができ、
37992679英文字、数字、下線、特別な文字列である C<::> と C<'> を含むことができます。
38002680この場合、最後の C<::> または C<'> の前は
38012681I<パッケージ限定子> として扱われます。
38022682L<perlmod> を参照して下さい。
38032683
38042684=begin original
38052685
38062686Perl variable names may also be a sequence of digits or a single
38072687punctuation or control character. These names are all reserved for
38082688special uses by Perl; for example, the all-digits names are used
38092689to hold data captured by backreferences after a regular expression
38102690match. Perl has a special syntax for the single-control-character
38112691names: It understands C<^X> (caret C<X>) to mean the control-C<X>
38122692character. For example, the notation C<$^W> (dollar-sign caret
38132693C<W>) is the scalar variable whose name is the single character
38142694control-C<W>. This is better than typing a literal control-C<W>
38152695into your program.
38162696
38172697=end original
38182698
38192699Perl の変数は、数字の列または一文字の句読点かコントロール文字の
38202700場合もあります。
38212701これらの名前は全て Perl によって特別な用途のために予約されています。
38222702例えば、全て数字の名前は正規表現マッチの後の後方参照のデータを
38232703保持するために用いられます。
38242704Perl には一文字のコントロール文字の名前のための特別な文法があります。
38252705C<^X>(キャレット C<X>)は control-C<X> キャラクタを意味します。
38262706例えば、C<$^W>(ドル記号 キャレット C<W>)は control-C<W> 一文字の
38272707名前をもつスカラ変数です。
38282708これはプログラム中にリテラルな control-C<W> をタイプするより
38292709良いです。
38302710
38312711=begin original
38322712
38332713Finally, new in Perl 5.6, Perl variable names may be alphanumeric
38342714strings that begin with control characters (or better yet, a caret).
38352715These variables must be written in the form C<${^Foo}>; the braces
38362716are not optional. C<${^Foo}> denotes the scalar variable whose
38372717name is a control-C<F> followed by two C<o>'s. These variables are
38382718reserved for future special uses by Perl, except for the ones that
38392719begin with C<^_> (control-underscore or caret-underscore). No
38402720control-character name that begins with C<^_> will acquire a special
38412721meaning in any future version of Perl; such names may therefore be
38422722used safely in programs. C<$^_> itself, however, I<is> reserved.
38432723
38442724=end original
38452725
38462726最後に、Perl 5.6 の新機能として、コントロール文字(もっと言えばキャレット)で
38472727始まる、英数字からなる文字列の変数名も使えます。
38482728これらの変数は C<${^Foo}> の形で書かれなければなりません。
38492729括弧は必須です。
38502730C<${^Foo}> はコントロール-C<F> の後に二つ C<o> が続く名前を持つ
38512731スカラ変数です。
38522732これらの変数は Perl によって特別な用途のために予約されていますが、
38532733C<^_> (コントロール-下線またはキャレット-下線)で始まるものは例外です。
38542734C<^_> で始まるコントロール文字名は Perl の将来のバージョンで
38552735特別な意味を持つことはありません。
38562736従ってこれらの名前はプログラム中で安全に使用できます。
38572737但し、C<$^_> そのものは I<予約されます>。
38582738
38592739=begin original
38602740
38612741Perl identifiers that begin with digits, control characters, or
38622742punctuation characters are exempt from the effects of the C<package>
3863declaration and are always forced to be in package C<main>; they are
2743declaration and are always forced to be in package C<main>. A few
3864also exempt from C<strict 'vars'> errors. A few other names are also
2744other names are also exempt:
3865exempt in these ways:
38662745
38672746=end original
38682747
38692748数字、コントロール文字、句読点で始まる Perl の識別子は
38702749C<package> 宣言の効果から逃れて、常に C<main> パッケージにあるものとして
38712750扱われます。さらに以下のものも逃れます:
38722751
38732752 ENV STDIN
38742753 INC STDOUT
38752754 ARGV STDERR
3876 ARGVOUT _
2755 ARGVOUT
38772756 SIG
38782757
38792758=begin original
38802759
38812760In particular, the new special C<${^_XYZ}> variables are always taken
38822761to be in package C<main>, regardless of any C<package> declarations
3883presently in scope.
2762presently in scope.
38842763
38852764=end original
38862765
38872766特に、新しい特別な C<${^_XYZ}> 変数はスコープ内の C<package> 宣言に関わらず
38882767常に C<main> パッケージとして扱われます。
38892768
38902769=head1 BUGS
38912770
38922771(バグ)
38932772
38942773=begin original
38952774
38962775Due to an unfortunate accident of Perl's implementation, C<use
38972776English> imposes a considerable performance penalty on all regular
38982777expression matches in a program, regardless of whether they occur
38992778in the scope of C<use English>. For that reason, saying C<use
39002779English> in libraries is strongly discouraged. See the
39012780Devel::SawAmpersand module documentation from CPAN
3902( http://www.cpan.org/modules/by-module/Devel/ )
2781(http://www.perl.com/CPAN/modules/by-module/Devel/)
3903for more information. Writing C<use English '-no_match_vars';>
2782for more information.
3904avoids the performance penalty.
39052783
39062784=end original
39072785
39082786Perl の実装における不幸な事故により、
39092787C<use English> はプログラム中の全ての正規表現マッチングにおいて
39102788かなりの性能低下を引き起こします。
39112789これは C<use English> のスコープ内かどうかに関わりません。
39122790この理由により、ライブラリで C<use English> を使うのは
39132791できるだけ避けてください。
39142792さらなる情報については CPAN の Devel::SawAmpersand モジュール
39152793(http://www.perl.com/CPAN/modules/by-module/Devel/) の
39162794ドキュメントを参照して下さい。
39172795
39182796=begin original
39192797
39202798Having to even think about the C<$^S> variable in your exception
39212799handlers is simply wrong. C<$SIG{__DIE__}> as currently implemented
39222800invites grievous and difficult to track down errors. Avoid it
39232801and use an C<END{}> or CORE::GLOBAL::die override instead.
39242802
39252803=end original
39262804
39272805例外ハンドラの中で C<$^S> を使おうなどとは考えてもいけません。
39282806現在の実装の C<$SIG{__DIE__}> は面倒を引き寄せ、エラーの追跡を困難にします。
39292807これの代わりに C<END{}> を使うか、CORE::GLOBAL::die をオーバーライドしてください。
39302808
39312809=begin meta
39322810
39332811Translate: 吉村 寿人 <JAE00534@niftyserve.or.jp> (5.000)
39342812Update: Kentaro Shirakata <argrath@ub32.org> (5.6.1-)
2813License: GPL or Artistic
39352814
39362815=end meta