perlvar > 5.12.1 との差分

perlvar 5.12.1 と 5.10.0 の差分

11
22=encoding euc-jp
33
44=head1 NAME
55
66=begin original
77
88perlvar - Perl predefined variables
99
1010=end original
1111
1212perlvar - Perl で定義済みの変数
1313
1414=head1 DESCRIPTION
1515
1616=head2 Predefined Names
1717
1818(定義済みの変数)
1919
2020=begin original
2121
2222The following names have special meaning to Perl. Most
2323punctuation names have reasonable mnemonics, or analogs in the
2424shells. Nevertheless, if you wish to use long variable names,
2525you need only say
2626
2727=end original
2828
2929以下の名前は Perl では特別な意味を持ちます。
3030記号的な名前の多くは記憶法があるか、シェルでの類推が可能です。
3131それでも長い名前を使用したい場合には
3232
3333 use English;
3434
3535=begin original
3636
3737at the top of your program. This aliases all the short names to the long
3838names in the current package. Some even have medium names, generally
3939borrowed from B<awk>. In general, it's best to use the
4040
4141=end original
4242
4343とプログラムの最初に書いてください。
4444これは、すべての短い名前の別名として、
4545カレントパッケージで長い名前を付けるものです。
4646B<awk> から持ってきた中間的な名前を持っているものもあります。
4747一般的に、一番良い使い方は:
4848
4949 use English '-no_match_vars';
5050
5151=begin original
5252
5353invocation if you don't need $PREMATCH, $MATCH, or $POSTMATCH, as it avoids
5454a certain performance hit with the use of regular expressions. See
5555L<English>.
5656
5757=end original
5858
5959と起動することで($PREMATCH, $MATCH, $POSTMATCH が不要の場合)、これにより
6060正規表現を使うときのパフォーマンスへの打撃を避けられます。
6161L<English> を参照してください。
6262
6363=begin original
6464
6565Variables that depend on the currently selected filehandle may be set by
6666calling an appropriate object method on the IO::Handle object, although
6767this is less efficient than using the regular built-in variables. (Summary
6868lines below for this contain the word HANDLE.) First you must say
6969
7070=end original
7171
7272現在選択されているファイルハンドルに
7373依存する変数の場合には、代わりに IO::Handle オブジェクトに
7474関するオブジェクトメソッドを呼び出して設定することができますが、
7575通常の組み込み変数よりは効率が落ちます。
7676(以下の要約では HANDLE という語を含んでいます。)
7777まず最初に必ず、
7878
7979 use IO::Handle;
8080
8181=begin original
8282
8383after which you may use either
8484
8585=end original
8686
8787と書き、その後で以下のように書くか、
8888
8989 method HANDLE EXPR
9090
9191=begin original
9292
9393or more safely,
9494
9595=end original
9696
9797もしくはより安全に以下のように書きます:
9898
9999 HANDLE->method(EXPR)
100100
101101=begin original
102102
103103Each method returns the old value of the IO::Handle attribute.
104104The methods each take an optional EXPR, which, if supplied, specifies the
105105new value for the IO::Handle attribute in question. If not supplied,
106106most methods do nothing to the current value--except for
107107autoflush(), which will assume a 1 for you, just to be different.
108108
109109=end original
110110
111111それぞれのメソッドは、IO::Handle 属性の昔の値を返します。
112112メソッドはそれぞれ EXPR をとることができ、指定した場合には、
113113問題の IO::Handle 属性の新しい値を指定することになります。
114114指定しない場合には、多くのメソッドでは現在の値に対して何もしませんが、
115115autoflush() では 1 を指定されたものとします。
116116
117117=begin original
118118
119119Because loading in the IO::Handle class is an expensive operation, you should
120120learn how to use the regular built-in variables.
121121
122122=end original
123123
124124IO::Handle クラスを読み込むのはコストの高い操作なので、
125125通常の組み込み変数の使い方を覚えるべきです。
126126
127127=begin original
128128
129129A few of these variables are considered "read-only". This means that if
130130you try to assign to this variable, either directly or indirectly through
131131a reference, you'll raise a run-time exception.
132132
133133=end original
134134
135135これらの変数の中には "read-only" として扱われるものもあります。
136136つまり、そういった変数に対して、直接にしろ、リファレンスを
137137介して間接にしろ、代入を行なおうとした場合には、実行時に
138138例外処理が起動されます。
139139
140140=begin original
141141
142142You should be very careful when modifying the default values of most
143143special variables described in this document. In most cases you want
144144to localize these variables before changing them, since if you don't,
145145the change may affect other modules which rely on the default values
146146of the special variables that you have changed. This is one of the
147147correct ways to read the whole file at once:
148148
149149=end original
150150
151151この文書に記述されているほとんどの特殊変数のデフォルト値を変更するときには
152152とても慎重になるべきです。
153153ほとんどの場合、これらの変数を変更する前にこれらをローカル化したいでしょう;
154154さもなければ、あなたが変更した特殊変数のデフォルト値に依存している
155155その他のモジュールにも影響を与えるかもしれないからです。
156156これはファイル全体を一度に読み込む正しい方法の一つです:
157157
158 open my $fh, "<", "foo" or die $!;
158 open my $fh, "foo" or die $!;
159159 local $/; # enable localized slurp mode
160160 my $content = <$fh>;
161161 close $fh;
162162
163163=begin original
164164
165165But the following code is quite bad:
166166
167167=end original
168168
169169しかし以下のコードは完全に悪いものです:
170170
171 open my $fh, "<", "foo" or die $!;
171 open my $fh, "foo" or die $!;
172172 undef $/; # enable slurp mode
173173 my $content = <$fh>;
174174 close $fh;
175175
176176=begin original
177177
178178since some other module, may want to read data from some file in the
179179default "line mode", so if the code we have just presented has been
180180executed, the global value of C<$/> is now changed for any other code
181181running inside the same Perl interpreter.
182182
183183=end original
184184
185185なぜなら、その他のモジュールでは、デフォルトの「行モード」でファイルを
186186読もうとするかも知れませんが、もし単に前述のコードを実行すると、
187187C<$/> のグローバルな値が、同じ Perl インタプリタ内で実行される
188188その他のコードに対しても変更されるからです。
189189
190190=begin original
191191
192192Usually when a variable is localized you want to make sure that this
193193change affects the shortest scope possible. So unless you are already
194194inside some short C<{}> block, you should create one yourself. For
195195example:
196196
197197=end original
198198
199199通常、変数をローカル化するとき、この変更ができるだけ最短のスコープに
200200影響を与えることを確実にしたいでしょう。
201201従って、既に小さい C<{}> ブロックの内側であるのでない限り、それを
202202自身で作るべきです。
203203例えば:
204204
205205 my $content = '';
206 open my $fh, "<", "foo" or die $!;
206 open my $fh, "foo" or die $!;
207207 {
208208 local $/;
209209 $content = <$fh>;
210210 }
211211 close $fh;
212212
213213=begin original
214214
215215Here is an example of how your own code can go broken:
216216
217217=end original
218218
219219以下はどのように自分のコードが壊れるかの例です:
220220
221221 for (1..5){
222222 nasty_break();
223223 print "$_ ";
224224 }
225225 sub nasty_break {
226226 $_ = 5;
227227 # do something with $_
228228 }
229229
230230=begin original
231231
232232You probably expect this code to print:
233233
234234=end original
235235
236236おそらくこのコードは以下のように表示されることを期待しています:
237237
238238 1 2 3 4 5
239239
240240=begin original
241241
242242but instead you get:
243243
244244=end original
245245
246246しかし、以下のようになります:
247247
248248 5 5 5 5 5
249249
250250=begin original
251251
252252Why? Because nasty_break() modifies C<$_> without localizing it
253253first. The fix is to add local():
254254
255255=end original
256256
257257なぜでしょう?
258258nasty_break() は C<$_> をローカル化する前に変更するからです。
259259修正するには、local() を追加します:
260260
261261 local $_ = 5;
262262
263263=begin original
264264
265265It's easy to notice the problem in such a short example, but in more
266266complicated code you are looking for trouble if you don't localize
267267changes to the special variables.
268268
269269=end original
270270
271271このような短い例では問題に気付くのは簡単ですが、より複雑なコードでは、
272272もし特殊変数の変更をローカル化していないと問題を探すことになります。
273273
274274=begin original
275275
276276The following list is ordered by scalar variables first, then the
277277arrays, then the hashes.
278278
279279=end original
280280
281281以下のリストはまずスカラ変数、それから配列、ハッシュの順に
282282並んでいます。
283283
284284=over 8
285285
286286=item $ARG
287287
288288=item $_
289289X<$_> X<$ARG>
290290
291291=begin original
292292
293293The default input and pattern-searching space. The following pairs are
294294equivalent:
295295
296296=end original
297297
298298デフォルトの入力とパターン検索のスペース。
299299以下の 2つは同値です:
300300
301301 while (<>) {...} # equivalent only in while!
302302 while (defined($_ = <>)) {...}
303303
304304 /^Subject:/
305305 $_ =~ /^Subject:/
306306
307307 tr/a-z/A-Z/
308308 $_ =~ tr/a-z/A-Z/
309309
310310 chomp
311311 chomp($_)
312312
313313=begin original
314314
315315Here are the places where Perl will assume $_ even if you
316316don't use it:
317317
318318=end original
319319
320320Perl が(あなたが使いたくなくても) $_ を仮定する場合がいくつかあります:
321321
322322=over 3
323323
324324=item *
325325
326326=begin original
327327
328The following functions:
328Various unary functions, including functions like ord() and int(), as well
329as the all file tests (C<-f>, C<-d>) except for C<-t>, which defaults to
330STDIN.
329331
330332=end original
331333
332様々な関数:
334様々な単項関数。ord() や int()、また C<-t> 以外の全ての
335ファイルテスト (C<-f>, C<-d>)など。C<-t> のデフォルトは STDIN です。
333336
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
350337=item *
351338
352339=begin original
353340
354All file tests (C<-f>, C<-d>) except for C<-t>, which defaults to STDIN.
341Various list functions like print() and unlink().
355See L<perlfunc/-X>
356342
357343=end original
358344
359デフォルトが STDIN である C<-t> を除く全てファイルテスト(C<-f>, C<-d>)
345print() unlink() など様々なリスト関数
360L<perlfunc/-X> を参照してください。
361346
362347=item *
363348
364349=begin original
365350
366The pattern matching operations C<m//>, C<s///> and C<tr///> (aka C<y///>)
351The pattern matching operations C<m//>, C<s///>, and C<tr///> when used
367when used without an C<=~> operator.
352without an C<=~> operator.
368353
369354=end original
370355
371C<=~> 演算子なしで用いられたパターンマッチ演算 C<m//>, C<s///>, C<tr///>
356C<=~> 演算子なしで用いられたパターンマッチ演算 C<m//>, C<s///>, C<tr///>
372(またの名を C<y///>)。
373357
374358=item *
375359
376360=begin original
377361
378362The default iterator variable in a C<foreach> loop if no other
379363variable is supplied.
380364
381365=end original
382366
383367C<foreach> ループでの他の変数が補われなかった場合のデフォルトの
384368繰り返し変数。
385369
386370=item *
387371
388372=begin original
389373
390374The implicit iterator variable in the grep() and map() functions.
391375
392376=end original
393377
394378grep() 関数と map() 関数の暗黙の繰り返し変数。
395379
396380=item *
397381
398382=begin original
399383
400The implicit variable of given().
401
402=end original
403
404given() の暗黙の変数。
405
406=item *
407
408=begin original
409
410384The default place to put an input record when a C<< <FH> >>
411385operation's result is tested by itself as the sole criterion of a C<while>
412386test. Outside a C<while> test, this will not happen.
413387
414388=end original
415389
416390C<< <FH> >> が単独で C<while> テストでテストされた場合の
417391結果を入れるデフォルトの場所。
418392C<while> テスト以外ではこれは起こりません。
419393
420394=back
421395
422396=begin original
423397
424398As C<$_> is a global variable, this may lead in some cases to unwanted
425399side-effects. As of perl 5.9.1, you can now use a lexical version of
426400C<$_> by declaring it in a file or in a block with C<my>. Moreover,
427401declaring C<our $_> restores the global C<$_> in the current scope.
428402
429403=end original
430404
431405C<$_> はグローバル変数なので、望まないような副作用を引き起こす場合があります。
432406perl 5.9.1 から、ファイルやブロックで C<my> で宣言することで、
433407レキシカル版の C<$_> が使えます。
434408さらに、C<our $_> という宣言は現在のスコープでグローバルな C<$_> を
435409再構築します。
436410
437411=begin original
438412
439413(Mnemonic: underline is understood in certain operations.)
440414
441415=end original
442416
443417(記憶法: 下線はある操作を覚えるためのもの。)
444418
445419=back
446420
447421=over 8
448422
449423=item $a
450424
451425=item $b
452426X<$a> X<$b>
453427
454428=begin original
455429
456430Special package variables when using sort(), see L<perlfunc/sort>.
457431Because of this specialness $a and $b don't need to be declared
458432(using use vars, or our()) even when using the C<strict 'vars'> pragma.
459433Don't lexicalize them with C<my $a> or C<my $b> if you want to be
460434able to use them in the sort() comparison block or function.
461435
462436=end original
463437
464438sort() を使うときの特殊パッケージ変数です; L<perlfunc/sort> を
465439参照してください。
466440この特殊性により、$a と $b は、たとえ C<strict 'vars'> を使っているときでも
467441(use vars や our() を使って) 宣言する必要がありません。
468442これを sort() 比較ブロックや関数で使えるようにしたい場合は、
469443C<my $a> や C<my $b> としてレキシカル化しないでください。
470444
471445=back
472446
473447=over 8
474448
475=item $<I<digits>> ($1, $2, ...)
449=item $<I<digits>>
476450X<$1> X<$2> X<$3>
477451
478452=begin original
479453
480454Contains the subpattern from the corresponding set of capturing
481parentheses from the last successful pattern match, not counting patterns
455parentheses from the last pattern match, not counting patterns
482456matched in nested blocks that have been exited already. (Mnemonic:
483457like \digits.) These variables are all read-only and dynamically
484458scoped to the current BLOCK.
485459
486460=end original
487461
488最後に成功したパターンマッチングで対応する括弧のサブパターンにマッチングした
462最後パターンマッチで対応する括弧のサブパターンにマッチした
489463文字列が入っているが、既に抜けてしまったブロックでの
490パターンマッチングは勘定に入れません
464パターンマッチは勘定に入れない
491465(記憶法: \(数字) のようなもの。)
492466これらの変数はすべて read-onlyで、現在の BLOCK に動的なスコープを持ちます。
493467
494468=item $MATCH
495469
496470=item $&
497471X<$&> X<$MATCH>
498472
499473=begin original
500474
501475The string matched by the last successful pattern match (not counting
502476any matches hidden within a BLOCK or eval() enclosed by the current
503477BLOCK). (Mnemonic: like & in some editors.) This variable is read-only
504478and dynamically scoped to the current BLOCK.
505479
506480=end original
507481
508482最後に成功したパターンマッチでマッチした文字列 (現在の
509483BLOCK で囲まれた BLOCK や eval() で隠れている部分でのマッチは
510484勘定に入れない)。
511485(記憶法: あるエディタの & ようなもの。)
512486この変数は read-only で、現在の BLOCK に動的なスコープを持ちます。
513487
514488=begin original
515489
516490The use of this variable anywhere in a program imposes a considerable
517491performance penalty on all regular expression matches. See L</BUGS>.
518492
519493=end original
520494
521495この変数をプログラムのどこかで使うと、プログラム中の全ての正規表現
522496マッチングにおいてかなりの性能低下を引き起こします。
523497L</BUGS> を参照して下さい。
524498
525499=begin original
526500
527501See L</@-> for a replacement.
528502
529503=end original
530504
531置き換えためには L</@-> を参照してください。
505置き換えためには L</@-> を参照してください。
532506
533507=item ${^MATCH}
534508X<${^MATCH}>
535509
536510=begin original
537511
538This is similar to C<$&> (C<$MATCH>) except that it does not incur the
512This is similar to C<$&> (C<$POSTMATCH>) except that it does not incur the
539513performance penalty associated with that variable, and is only guaranteed
540514to return a defined value when the pattern was compiled or executed with
541515the C</p> modifier.
542516
543517=end original
544518
545これは C<$&> (C<$MATCH>) と同様ですが、この変数と関連付けられた性能上の
519これは C<$&> (C<$POSTMATCH>) と同様ですが、この変数と関連付けられた性能上の
546520ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された
547521場合にのみ定義された値を返すことが保証されます。
548522
549523=item $PREMATCH
550524
551525=item $`
552526X<$`> X<$PREMATCH>
553527
554528=begin original
555529
556530The string preceding whatever was matched by the last successful
557531pattern match (not counting any matches hidden within a BLOCK or eval
558532enclosed by the current BLOCK). (Mnemonic: C<`> often precedes a quoted
559533string.) This variable is read-only.
560534
561535=end original
562536
563537最後の成功したパターンマッチ (現在のBLOCK で囲まれた
564538BLOCK や eval() に隠れている部分でのマッチは勘定に入れない) で
565539マッチした部分の前の文字列。
566540(記憶法: C<`> は多くの場合クォートされた文字列の前にある。)
567541この変数は read-only です。
568542
569543=begin original
570544
571545The use of this variable anywhere in a program imposes a considerable
572546performance penalty on all regular expression matches. See L</BUGS>.
573547
574548=end original
575549
576550この変数をプログラムのどこかで使うと、プログラム中の全ての正規表現
577551マッチングにおいてかなりの性能低下を引き起こします。
578552L</BUGS> を参照して下さい。
579553
580554=begin original
581555
582556See L</@-> for a replacement.
583557
584558=end original
585559
586560置き換えのためには L</@-> を参照してください。
587561
588562=item ${^PREMATCH}
589563X<${^PREMATCH}>
590564
591565=begin original
592566
593567This is similar to C<$`> ($PREMATCH) except that it does not incur the
594568performance penalty associated with that variable, and is only guaranteed
595569to return a defined value when the pattern was compiled or executed with
596570the C</p> modifier.
597571
598572=end original
599573
600574これは C<$`> ($PREMATCH) と同様ですが、この変数と関連付けられた性能上の
601575ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された
602576場合にのみ定義された値を返すことが保証されます。
603577
604578=item $POSTMATCH
605579
606580=item $'
607581X<$'> X<$POSTMATCH>
608582
609583=begin original
610584
611585The string following whatever was matched by the last successful
612586pattern match (not counting any matches hidden within a BLOCK or eval()
613587enclosed by the current BLOCK). (Mnemonic: C<'> often follows a quoted
614588string.) Example:
615589
616590=end original
617591
618592最後の成功したパターンマッチ (現在のBLOCK で囲まれた
619593BLOCK や eval() に隠れている部分でのマッチは勘定に入れない) で
620594マッチした部分に続く文字列。
621595(記憶法: C<'> は多くの場合クォートされた文字列の後にある。) 例:
622596
623597 local $_ = 'abcdefghi';
624598 /def/;
625599 print "$`:$&:$'\n"; # prints abc:def:ghi
626600
627601=begin original
628602
629603This variable is read-only and dynamically scoped to the current BLOCK.
630604
631605=end original
632606
633607この変数は read-only で、現在の BLOCK に動的なスコープを持ちます。
634608
635609=begin original
636610
637611The use of this variable anywhere in a program imposes a considerable
638612performance penalty on all regular expression matches. See L</BUGS>.
639613
640614=end original
641615
642616この変数をプログラムのどこかで使うと、プログラム中の全ての正規表現
643617マッチングにおいてかなりの性能低下を引き起こします。
644618L</BUGS> を参照して下さい。
645619
646620=begin original
647621
648622See L</@-> for a replacement.
649623
650624=end original
651625
652626置き換えのためには L</@-> を参照してください。
653627
654628=item ${^POSTMATCH}
655629X<${^POSTMATCH}>
656630
657631=begin original
658632
659633This is similar to C<$'> (C<$POSTMATCH>) except that it does not incur the
660634performance penalty associated with that variable, and is only guaranteed
661635to return a defined value when the pattern was compiled or executed with
662636the C</p> modifier.
663637
664638=end original
665639
666640これは C<$'> (C<$POSTMATCH>) と同様ですが、この変数と関連付けられた性能上の
667641ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された
668642場合にのみ定義された値を返すことが保証されます。
669643
670644=item $LAST_PAREN_MATCH
671645
672646=item $+
673647X<$+> X<$LAST_PAREN_MATCH>
674648
675649=begin original
676650
677651The text matched by the last bracket of the last successful search pattern.
678652This is useful if you don't know which one of a set of alternative patterns
679653matched. For example:
680654
681655=end original
682656
683657最後に検索されたパターンの最後の括弧にマッチした文字列。
684658これはいくつかの選択肢の中でどれがマッチするのか
685659わからないような場合に使うと便利です。たとえば:
686660
687661 /Version: (.*)|Revision: (.*)/ && ($rev = $+);
688662
689663=begin original
690664
691665(Mnemonic: be positive and forward looking.)
692666This variable is read-only and dynamically scoped to the current BLOCK.
693667
694668=end original
695669
696670(記憶法: ポジティブで前向き。)
697671この変数は read-only で、現在の BLOCK に動的なスコープを持ちます。
698672
699673=item $LAST_SUBMATCH_RESULT
700674
701675=item $^N
702676X<$^N>
703677
704678=begin original
705679
706680The text matched by the used group most-recently closed (i.e. the group
707681with the rightmost closing parenthesis) of the last successful search
708682pattern. (Mnemonic: the (possibly) Nested parenthesis that most
709683recently closed.)
710684
711685=end original
712686
713687最近のマッチングに成功した検索パターンのうち、一番最近に閉じられた
714688使われたグループ(つまり、一番右の閉じかっこのグループ)にマッチングした
715689テキスト。
716690(記憶法: もっとも最近閉じられた、(おそらく) ネストした (Nested) かっこ。)
717691
718692=begin original
719693
720694This is primarily used inside C<(?{...})> blocks for examining text
721695recently matched. For example, to effectively capture text to a variable
722696(in addition to C<$1>, C<$2>, etc.), replace C<(...)> with
723697
724698=end original
725699
726700これは主として最近マッチしたテキストを調べるために C<(?{...})> ブロックの
727701中で使われます。
728702例えば、(C<$1>, C<$2> などに加えて) テキストを変数に効率的に捕捉するには、
729703C<(...)> を以下で置き換えます:
730704
731705 (?:(...)(?{ $var = $^N }))
732706
733707=begin original
734708
735709By setting and then using C<$var> in this way relieves you from having to
736710worry about exactly which numbered set of parentheses they are.
737711
738712=end original
739713
740714C<$var> をこの方法で設定してから使うことで、かっこの組の番号について
741715気にしなくてすむようになります。
742716
743717=begin original
744718
745719This variable is dynamically scoped to the current BLOCK.
746720
747721=end original
748722
749723この変数は現在の BLOCK に動的なスコープを持ちます。
750724
751725=item @LAST_MATCH_END
752726
753727=item @+
754728X<@+> X<@LAST_MATCH_END>
755729
756730=begin original
757731
758732This array holds the offsets of the ends of the last successful
759733submatches in the currently active dynamic scope. C<$+[0]> is
760734the offset into the string of the end of the entire match. This
761735is the same value as what the C<pos> function returns when called
762736on the variable that was matched against. The I<n>th element
763737of this array holds the offset of the I<n>th submatch, so
764738C<$+[1]> is the offset past where $1 ends, C<$+[2]> the offset
765739past where $2 ends, and so on. You can use C<$#+> to determine
766740how many subgroups were in the last successful match. See the
767741examples given for the C<@-> variable.
768742
769743=end original
770744
771745この配列は、現在アクティブな動的スコープで最後に成功した
772746サブマッチの最後へのオフセットを保持します。
773747C<$+[0]> はマッチ全体の文字列の最後へのオフセットです。
774748これはマッチした変数に対して C<pos> 関数を呼び出したときの
775749返り値と同じです。
776750この配列の I<n> 番目の要素は I<n> 番目のサブマッチのオフセットを
777751保持していますので、C<$+[1]> は過去の $1 の終わりのオフセット、
778752C<$+[2]> は $2 のオフセット、という形になります。
779753C<$#+> は最後に成功したマッチでいくつサブグループがあるかを
780754決定するのに使えます。
781755C<@-> 変数の例を参照して下さい。
782756
783=item %LAST_PAREN_MATCH
784
785757=item %+
786758X<%+>
787759
788760=begin original
789761
790762Similar to C<@+>, the C<%+> hash allows access to the named capture
791763buffers, should they exist, in the last successful match in the
792764currently active dynamic scope.
793765
794766=end original
795767
796768C<@+> と同様、C<%+> ハッシュは、現在アクティブな動的スコープで最後に成功した
797769マッチングの名前付き捕捉バッファ(存在すれば)へのアクセスを可能にします。
798770
799771=begin original
800772
801773For example, C<$+{foo}> is equivalent to C<$1> after the following match:
802774
803775=end original
804776
805777例えば、C<$+{foo}> は以下のマッチングの後の C<$1> と等価です:
806778
807779 'foo' =~ /(?<foo>foo)/;
808780
809781=begin original
810782
811783The keys of the C<%+> hash list only the names of buffers that have
812784captured (and that are thus associated to defined values).
813785
814786=end original
815787
816788C<%+> ハッシュのキーは捕捉された(従って定義された値と結びついている)
817789バッファの名前のみの一覧です。
818790
819791=begin original
820792
821793The underlying behaviour of C<%+> is provided by the
822794L<Tie::Hash::NamedCapture> module.
823795
824796=end original
825797
826798C<%+> の基礎となる振る舞いは L<Tie::Hash::NamedCapture> モジュールで
827799提供されています。
828800
829801=begin original
830802
831803B<Note:> C<%-> and C<%+> are tied views into a common internal hash
832804associated with the last successful regular expression. Therefore mixing
833805iterative access to them via C<each> may have unpredictable results.
834806Likewise, if the last successful match changes, then the results may be
835807surprising.
836808
837809=end original
838810
839811B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の
840812内部ハッシュと tie されたビューです。
841813従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果と
842814なります。
843815同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。
844816
845817=item HANDLE->input_line_number(EXPR)
846818
847819=item $INPUT_LINE_NUMBER
848820
849821=item $NR
850822
851823=item $.
852824X<$.> X<$NR> X<$INPUT_LINE_NUMBER> X<line number>
853825
854826=begin original
855827
856828Current line number for the last filehandle accessed.
857829
858830=end original
859831
860832最後にアクセスされたファイルハンドルの現在の行番号。
861833
862834=begin original
863835
864836Each filehandle in Perl counts the number of lines that have been read
865837from it. (Depending on the value of C<$/>, Perl's idea of what
866838constitutes a line may not match yours.) When a line is read from a
867839filehandle (via readline() or C<< <> >>), or when tell() or seek() is
868840called on it, C<$.> becomes an alias to the line counter for that
869841filehandle.
870842
871843=end original
872844
873845Perl の各ファイルハンドルは、そこから読み込んだ行数を数えています。
874846(C<$/> の値に依存して、何が行を構成するかに関する Perl の考えはあなたの
875847考えと一致しないかもしれません。)
876848行が(readline() や C<< <> >> を使って)ファイルハンドルから読み込まれたか、
877849tell() や seek() がファイルハンドルに対して呼び出された場合、
878850C<$.> はそのファイルハンドルの行カウンタへのエイリアスとなります。
879851
880852=begin original
881853
882854You can adjust the counter by assigning to C<$.>, but this will not
883855actually move the seek pointer. I<Localizing C<$.> will not localize
884856the filehandle's line count>. Instead, it will localize perl's notion
885857of which filehandle C<$.> is currently aliased to.
886858
887859=end original
888860
889861C<$.> へ代入することでカウンタの値を修正できますが、これは実際にシーク
890862ポインタを動かすことはありません。
891863I<C<$.> をローカル化してもファイルハンドルの行カウンタは
892864ローカル化されません>。
893865代わりに、現在 C<$.> がどのファイルハンドルへのエイリアスかという情報が
894866ローカル化されます。
895867
896868=begin original
897869
898870C<$.> is reset when the filehandle is closed, but B<not> when an open
899871filehandle is reopened without an intervening close(). For more
900872details, see L<perlop/"IE<sol>O Operators">. Because C<< <> >> never does
901873an explicit close, line numbers increase across ARGV files (but see
902874examples in L<perlfunc/eof>).
903875
904876=end original
905877
906878C<$.> はファイルハンドルがクローズされるとリセットされますが、
907879オープンしているファイルハンドルが close() されることなく再オープンされた
908880場合にはリセット B<されません>。
909881さらなる詳細については、L<perlop/"IE<sol>O Operators"> を参照してください。
910882なぜなら、 C<< <> >> は決して明示的なクローズは行わず、行番号は ARGV の
911883ファイル間で通算してカウントされるからです(但し L<perlfunc/eof> の例を
912884参照してください)。
913885
914886=begin original
915887
916888You can also use C<< HANDLE->input_line_number(EXPR) >> to access the
917889line counter for a given filehandle without having to worry about
918890which handle you last accessed.
919891
920892=end original
921893
922894また、C<< HANDLE->input_line_number(EXPR) >> とすることで、どのハンドルに
923895最後にアクセスしたかを気にすることなく行カウンタにアクセスできます。
924896
925897=begin original
926898
927899(Mnemonic: many programs use "." to mean the current line number.)
928900
929901=end original
930902
931903(記憶法: 多くのプログラムで "." が現在行番号を示すように使われています。)
932904
933905=item IO::Handle->input_record_separator(EXPR)
934906
935907=item $INPUT_RECORD_SEPARATOR
936908
937909=item $RS
938910
939911=item $/
940912X<$/> X<$RS> X<$INPUT_RECORD_SEPARATOR>
941913
942914=begin original
943915
944916The input record separator, newline by default. This
945917influences Perl's idea of what a "line" is. Works like B<awk>'s RS
946918variable, including treating empty lines as a terminator if set to
947919the null string. (An empty line cannot contain any spaces
948920or tabs.) You may set it to a multi-character string to match a
949921multi-character terminator, or to C<undef> to read through the end
950922of file. Setting it to C<"\n\n"> means something slightly
951923different than setting to C<"">, if the file contains consecutive
952924empty lines. Setting to C<""> will treat two or more consecutive
953925empty lines as a single empty line. Setting to C<"\n\n"> will
954926blindly assume that the next input character belongs to the next
955927paragraph, even if it's a newline. (Mnemonic: / delimits
956928line boundaries when quoting poetry.)
957929
958930=end original
959931
960932入力レコードセパレータで、デフォルトでは改行文字。
961933これは Perl での「行」とは何か、ということに影響を与えます。
962934空文字列に設定されると、空行をセパレータとして扱うことを
963935含めて、B<awk> の変数 RS のように働きます
964936(空行はスペースやタブを含んでいてはいけません)。
965937複数文字の区切文字を示すために、文字列を設定することもできます。
966938また、ファイルの最後まで読み込むために undef を指定することもできます。
967939この変数に C<"\n\n"> を設定すると、空行が続く場合において、
968940C<""> を設定した場合とわずかに違う動作をするようになります。
969941C<""> を設定した場合には、複数の空行も 1 つの空行であるかのように扱います。
970942C<"\n\n"> を設定した場合には、単純に次の文字が (たとえ改行文字であっても)
971943次の段落に含まれるものとして扱います。
972944(記憶法: /は、詩を引用するときに、行の区切りを示します。)
973945
974946 local $/; # enable "slurp" mode
975947 local $_ = <FH>; # whole file now here
976948 s/\n[ \t]+/ /g;
977949
978950=begin original
979951
980952Remember: the value of C<$/> is a string, not a regex. B<awk> has to be
981953better for something. :-)
982954
983955=end original
984956
985957注意: C<$/> は文字列であり、正規表現ではありません。
986958B<awk> は何かもっとうまくやらなくてはいけません。:-)
987959
988960=begin original
989961
990962Setting C<$/> to a reference to an integer, scalar containing an integer, or
991963scalar that's convertible to an integer will attempt to read records
992964instead of lines, with the maximum record size being the referenced
993965integer. So this:
994966
995967=end original
996968
997969C<$/> に整数、整数を含むスカラ、整数に変換できるスカラのいずれかへの
998970リファレンスをセットすると、行を読む代わりにレコードを読もうとします。
999971この場合、最大レコードサイズはリファレンス先の整数値となります。つまり:
1000972
1001973 local $/ = \32768; # or \"32768", or \$var_containing_32768
1002 open my $fh, "<", $myfile or die $!;
974 open my $fh, $myfile or die $!;
1003975 local $_ = <$fh>;
1004976
1005977=begin original
1006978
1007979will read a record of no more than 32768 bytes from FILE. If you're
1008980not reading from a record-oriented file (or your OS doesn't have
1009981record-oriented files), then you'll likely get a full chunk of data
1010982with every read. If a record is larger than the record size you've
1011983set, you'll get the record back in pieces. Trying to set the record
1012984size to zero or less will cause reading in the (rest of the) whole file.
1013985
1014986=end original
1015987
1016988これは FILE から 32768 バイトを超えないようにレコードを読み込みます。
1017989もしレコード指向のファイルを読み込まない場合
1018990(あるいは OS がレコード指向ファイルを持たない場合)、
1019991読み込み毎にデータのチャンク全部を取り込みます。
1020992もしレコードがセットしたレコードサイズより大きい場合、
1021993レコードの部分を取り込みます。
1022994レコードサイズを 0 以下にセットしようとすると、(残りの)ファイル全体を
1023995読み込むことになります。
1024996
1025997=begin original
1026998
1027999On VMS, record reads are done with the equivalent of C<sysread>,
10281000so it's best not to mix record and non-record reads on the same
10291001file. (This is unlikely to be a problem, because any file you'd
10301002want to read in record mode is probably unusable in line mode.)
10311003Non-VMS systems do normal I/O, so it's safe to mix record and
10321004non-record reads of a file.
10331005
10341006=end original
10351007
10361008VMS では、レコード読み込みは C<sysread> と等価に行われますので、
10371009レコード読み込みと非レコード読み込みを同じファイルで混ぜないのが
10381010最善です。(これはあまり問題になりません。なぜなら
10391011レコード読み込みしたいファイルは多分行モードでは使えないものだからです。)
10401012VMS 以外のシステムでは普通の I/O を使いますので、
10411013同じファイルのレコード読み込みと非レコード読み込みを混ぜても安全です。
10421014
10431015=begin original
10441016
10451017See also L<perlport/"Newlines">. Also see C<$.>.
10461018
10471019=end original
10481020
10491021L<perlport/"Newlines"> と C<$.> も参照してください。
10501022
10511023=item HANDLE->autoflush(EXPR)
10521024
10531025=item $OUTPUT_AUTOFLUSH
10541026
10551027=item $|
10561028X<$|> X<autoflush> X<flush> X<$OUTPUT_AUTOFLUSH>
10571029
10581030=begin original
10591031
10601032If set to nonzero, forces a flush right away and after every write
10611033or print on the currently selected output channel. Default is 0
10621034(regardless of whether the channel is really buffered by the
10631035system or not; C<$|> tells you only whether you've asked Perl
10641036explicitly to flush after each write). STDOUT will
10651037typically be line buffered if output is to the terminal and block
10661038buffered otherwise. Setting this variable is useful primarily when
10671039you are outputting to a pipe or socket, such as when you are running
10681040a Perl program under B<rsh> and want to see the output as it's
10691041happening. This has no effect on input buffering. See L<perlfunc/getc>
1070for that. See L<perldoc/select> on how to select the output channel.
1042for 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.)
10721043
10731044=end original
10741045
107510460 以外に設定されると、
10761047その時点で選択されている出力チャネルを
10771048直ちにその場でフラッシュし、
10781049さらに write や print を行なうごとに、強制的にフラッシュします。
10791050デフォルトでは 0 となっています
10801051(チャンネルが実際にシステムによってバッファリングされているかどうかは
10811052関知しません。C<$|> は Perl が明示的に毎回書き込みの後に
10821053フラッシュするかどうかのみを示します)。
10831054STDOUT は通常では、端末への出力時には行バッファリング、
10841055それ以外ではブロックバッファリングであることに注意してください。
10851056これは、Perl のスクリプトを rsh 配下で実行して、
1086実行状況を確認したい場合のように、パイプやソケットに出力するときに特に
1057実行状況を確認したい場合のように、パイプやソケットに出力するときに特に便利でしょう。
1087便利でしょう。
10881058これは入力バッファリングには何の影響も与えません。
1089出力チャネルの選択方法については L<perldoc/select> を参照してください。
1090L<IO::Handle> も参照してください。
10911059(記憶法: パイプをホットな状態にしておくために使う。)
10921060
10931061=item IO::Handle->output_field_separator EXPR
10941062
10951063=item $OUTPUT_FIELD_SEPARATOR
10961064
10971065=item $OFS
10981066
10991067=item $,
11001068X<$,> X<$OFS> X<$OUTPUT_FIELD_SEPARATOR>
11011069
11021070=begin original
11031071
11041072The output field separator for the print operator. If defined, this
11051073value is printed between each of print's arguments. Default is C<undef>.
11061074(Mnemonic: what is printed when there is a "," in your print statement.)
11071075
11081076=end original
11091077
11101078print 演算子のための出力フィールドセパレータ。
11111079定義されると、この値がそれぞれの print の引数の間に表示されます。
11121080デフォルトは C<undef> です。
11131081(記憶法: print 文で "," を書いた場所に印字されるもの。)
11141082
11151083=item IO::Handle->output_record_separator EXPR
11161084
11171085=item $OUTPUT_RECORD_SEPARATOR
11181086
11191087=item $ORS
11201088
11211089=item $\
11221090X<$\> X<$ORS> X<$OUTPUT_RECORD_SEPARATOR>
11231091
11241092=begin original
11251093
11261094The output record separator for the print operator. If defined, this
11271095value is printed after the last of print's arguments. Default is C<undef>.
11281096(Mnemonic: you set C<$\> instead of adding "\n" at the end of the print.
11291097Also, it's just like C<$/>, but it's what you get "back" from Perl.)
11301098
11311099=end original
11321100
11331101print 演算子のための出力レコードセパレータ。
11341102もし定義されていると、print の最後の引数の最後にこの値が表示されます。
11351103デフォルトは C<undef> です。
11361104(記憶法: print の最後に "\n" を付け加える代わりに C<$\> を設定する。
11371105また、C<$/> に似通っているが、Perl から「バック」されるものです。)
11381106
11391107=item $LIST_SEPARATOR
11401108
11411109=item $"
11421110X<$"> X<$LIST_SEPARATOR>
11431111
11441112=begin original
11451113
11461114This is like C<$,> except that it applies to array and slice values
11471115interpolated into a double-quoted string (or similar interpreted
11481116string). Default is a space. (Mnemonic: obvious, I think.)
11491117
11501118=end original
11511119
11521120C<$,> と同様ですが、これは 2 重引用符で括られた文字列
11531121(または、同様に扱われる文字列) 内で配列とスライスの値が展開される
11541122際に適用されます。
11551123デフォルトではスペースになっています。(記憶法: 明らかでしょう。)
11561124
11571125=item $SUBSCRIPT_SEPARATOR
11581126
11591127=item $SUBSEP
11601128
11611129=item $;
11621130X<$;> X<$SUBSEP> X<SUBSCRIPT_SEPARATOR>
11631131
11641132=begin original
11651133
11661134The subscript separator for multidimensional array emulation. If you
11671135refer to a hash element as
11681136
11691137=end original
11701138
11711139多次元配列のエミュレートのための添え字の区切文字。
11721140ハッシュの要素を
11731141
11741142 $foo{$a,$b,$c}
11751143
11761144=begin original
11771145
11781146it really means
11791147
11801148=end original
11811149
11821150のようにして参照すると、実際には
11831151
11841152 $foo{join($;, $a, $b, $c)}
11851153
11861154=begin original
11871155
11881156But don't put
11891157
11901158=end original
11911159
11921160という意味になります。
11931161しかし、
11941162
11951163 @foo{$a,$b,$c} # a slice--note the @
11961164
11971165=begin original
11981166
11991167which means
12001168
12011169=end original
12021170
12031171としてはいけません。
12041172これは以下の意味になります。
12051173
12061174 ($foo{$a},$foo{$b},$foo{$c})
12071175
12081176=begin original
12091177
12101178Default is "\034", the same as SUBSEP in B<awk>. If your
12111179keys contain binary data there might not be any safe value for C<$;>.
12121180(Mnemonic: comma (the syntactic subscript separator) is a
12131181semi-semicolon. Yeah, I know, it's pretty lame, but C<$,> is already
12141182taken for something more important.)
12151183
12161184=end original
12171185
12181186デフォルトは "\034" で、C<awk> の SUBSEP と同じです。
12191187使おうとしている key の値がバイナリのデータを含むならば、
12201188C<$;> に設定する安全な値などはないことになります。
12211189(記憶法: コンマ (構文上の添え字区切り文字) は
12221190セミ−セミコロンなのです。
12231191ええ、詭弁だとはわかってますが、C<$,> はもう既にもっと
12241192重要な任務を持ってるんです。)
12251193
12261194=begin original
12271195
12281196Consider using "real" multidimensional arrays as described
12291197in L<perllol>.
12301198
12311199=end original
12321200
12331201L<perllol> で記述している「本物の」多次元配列を使うようにしてください。
12341202
12351203=item HANDLE->format_page_number(EXPR)
12361204
12371205=item $FORMAT_PAGE_NUMBER
12381206
12391207=item $%
12401208X<$%> X<$FORMAT_PAGE_NUMBER>
12411209
12421210=begin original
12431211
12441212The current page number of the currently selected output channel.
12451213Used with formats.
12461214(Mnemonic: % is page number in B<nroff>.)
12471215
12481216=end original
12491217
12501218その時点で選択されている出力チャネルの、その時点でのページ番号。
12511219フォーマットで用いられます。
12521220(記憶法: % は、B<nroff> でのページ番号です。)
12531221
12541222=item HANDLE->format_lines_per_page(EXPR)
12551223
12561224=item $FORMAT_LINES_PER_PAGE
12571225
12581226=item $=
12591227X<$=> X<$FORMAT_LINES_PER_PAGE>
12601228
12611229=begin original
12621230
12631231The current page length (printable lines) of the currently selected
12641232output channel. Default is 60.
12651233Used with formats.
12661234(Mnemonic: = has horizontal lines.)
12671235
12681236=end original
12691237
12701238その時点で選択されている出力チャネルの、その時点での
12711239ページ長 (印字可能行数)。デフォルトは 60 です。
12721240フォーマットで用いられます。
12731241(記憶法: = には複数の水平線 (行) が含まれます。)
12741242
12751243=item HANDLE->format_lines_left(EXPR)
12761244
12771245=item $FORMAT_LINES_LEFT
12781246
12791247=item $-
12801248X<$-> X<$FORMAT_LINES_LEFT>
12811249
12821250=begin original
12831251
12841252The number of lines left on the page of the currently selected output
12851253channel.
12861254Used with formats.
12871255(Mnemonic: lines_on_page - lines_printed.)
12881256
12891257=end original
12901258
12911259その時点で選択されている出力チャネルの、ページに残っている行数。
12921260フォーマットで用いられます。
12931261(記憶法: "ページ行数" - "印字済み行数")
12941262
12951263=item @LAST_MATCH_START
12961264
12971265=item @-
12981266X<@-> X<@LAST_MATCH_START>
12991267
13001268=begin original
13011269
13021270$-[0] is the offset of the start of the last successful match.
13031271C<$-[>I<n>C<]> is the offset of the start of the substring matched by
13041272I<n>-th subpattern, or undef if the subpattern did not match.
13051273
13061274=end original
13071275
13081276$-[0] は最後に成功したマッチの先頭のオフセットです。
13091277C<$-[>I<n>C<]> は I<n> 番目のサブパターンにマッチした部分文字列の
13101278先頭のオフセットです。サブパターンがマッチしなかった場合は undef です。
13111279
13121280=begin original
13131281
13141282Thus after a match against $_, $& coincides with C<substr $_, $-[0],
13151283$+[0] - $-[0]>. Similarly, $I<n> coincides with C<substr $_, $-[n],
13161284$+[n] - $-[n]> if C<$-[n]> is defined, and $+ coincides with
13171285C<substr $_, $-[$#-], $+[$#-] - $-[$#-]>. One can use C<$#-> to find the last
13181286matched subgroup in the last successful match. Contrast with
13191287C<$#+>, the number of subgroups in the regular expression. Compare
13201288with C<@+>.
13211289
13221290=end original
13231291
13241292従って $_ のマッチの後、$& は C<substr $_, $-[0], $+[0] - $-[0]> と
13251293一致します。同様に、$I<n> は、C<$-[n]> が定義されていれば
13261294C<substr $_, $-[n], $+[n] - $-[n]> と一致し、
13271295$+ は C<substr $_, $-[$#-], $+[$#-] - $-[$#-]> と一致します。
13281296C<$#-> は直前に成功したマッチで最後のマッチしたサブグループを
13291297探すのに使えます。
13301298正規表現でのサブグループの数である C<$#+> と対照的です。
13311299C<@+> と比較してください。
13321300
13331301=begin original
13341302
13351303This array holds the offsets of the beginnings of the last
13361304successful submatches in the currently active dynamic scope.
13371305C<$-[0]> is the offset into the string of the beginning of the
13381306entire match. The I<n>th element of this array holds the offset
13391307of the I<n>th submatch, so C<$-[1]> is the offset where $1
13401308begins, C<$-[2]> the offset where $2 begins, and so on.
13411309
13421310=end original
13431311
13441312この配列は現在アクティブな動的スコープ内で最後に成功した
13451313サブマッチの先頭位置のオフセットを保持します。
13461314C<$-[0]> はマッチ全体の先頭の文字列へのオフセットです。
13471315この配列の I<n> 番目の要素は I<n> 番目のサブマッチへの
13481316オフセットを保持しますので、C<$-[1]> は $1 の先頭への
13491317オフセット、C<$-[2]> は $2 の先頭へのオフセット、などとなります。
13501318
13511319=begin original
13521320
13531321After a match against some variable $var:
13541322
13551323=end original
13561324
13571325ある変数 $var でマッチした後、以下のようになります。
13581326
1327=begin original
1328
13591329=over 5
13601330
13611331=item C<$`> is the same as C<substr($var, 0, $-[0])>
13621332
1363(C<$`> は C<substr($var, 0, $-[0])> と同じです。)
1364
13651333=item C<$&> is the same as C<substr($var, $-[0], $+[0] - $-[0])>
13661334
1367(C<$&> は C<substr($var, $-[0], $+[0] - $-[0])> と同じです。)
1368
13691335=item C<$'> is the same as C<substr($var, $+[0])>
13701336
1371(C<$'> は C<substr($var, $+[0])> と同じです。)
1372
13731337=item C<$1> is the same as C<substr($var, $-[1], $+[1] - $-[1])>
13741338
1375(C<$1> は C<substr($var, $-[1], $+[1] - $-[1])> と同じです。)
1376
13771339=item C<$2> is the same as C<substr($var, $-[2], $+[2] - $-[2])>
13781340
1379(C<$2> は C<substr($var, $-[2], $+[2] - $-[2])> と同じです。)
1380
13811341=item C<$3> is the same as C<substr($var, $-[3], $+[3] - $-[3])>
13821342
1383(C<$3> は C<substr $var, $-[3], $+[3] - $-[3])> と同じです。)
1343=back
13841344
1345=end original
1346
1347=over 5
1348
1349=item C<$`> は C<substr($var, 0, $-[0])> と同じです。
1350
1351=item C<$&> は C<substr($var, $-[0], $+[0] - $-[0])> と同じです。
1352
1353=item C<$'> は C<substr($var, $+[0])> と同じです。
1354
1355=item C<$1> は C<substr($var, $-[1], $+[1] - $-[1])> と同じです。
1356
1357=item C<$2> は C<substr($var, $-[2], $+[2] - $-[2])> と同じです。
1358
1359=item C<$3> は C<substr $var, $-[3], $+[3] - $-[3])> と同じです。
1360
13851361=back
13861362
13871363=item %-
13881364X<%->
13891365
13901366=begin original
13911367
13921368Similar to C<%+>, this variable allows access to the named capture buffers
13931369in the last successful match in the currently active dynamic scope. To
13941370each capture buffer name found in the regular expression, it associates a
13951371reference to an array containing the list of values captured by all
13961372buffers with that name (should there be several of them), in the order
13971373where they appear.
13981374
13991375=end original
14001376
14011377C<%+> と同様、この変数は現在アクティブな動的スコープで最後に成功した
14021378マッチングの名前付き捕捉バッファへのアクセスを可能にします。
14031379正規表現中に捕捉バッファ名が現れるごとに、その名前のバッファ全てで
14041380(複数あるでしょう)捕捉されている値のリストを出現順で含む配列への
14051381リファレンスと関連付けられます。
14061382
14071383=begin original
14081384
14091385Here's an example:
14101386
14111387=end original
14121388
14131389以下に例を示します:
14141390
14151391 if ('1234' =~ /(?<A>1)(?<B>2)(?<A>3)(?<B>4)/) {
14161392 foreach my $bufname (sort keys %-) {
14171393 my $ary = $-{$bufname};
14181394 foreach my $idx (0..$#$ary) {
14191395 print "\$-{$bufname}[$idx] : ",
14201396 (defined($ary->[$idx]) ? "'$ary->[$idx]'" : "undef"),
14211397 "\n";
14221398 }
14231399 }
14241400 }
14251401
14261402=begin original
14271403
14281404would print out:
14291405
14301406=end original
14311407
14321408とすると、以下のものが表示されます:
14331409
14341410 $-{A}[0] : '1'
14351411 $-{A}[1] : '3'
14361412 $-{B}[0] : '2'
14371413 $-{B}[1] : '4'
14381414
14391415=begin original
14401416
14411417The keys of the C<%-> hash correspond to all buffer names found in
14421418the regular expression.
14431419
14441420=end original
14451421
14461422C<%-> ハッシュのキーは正規表現で見つかった全てのバッファ名に対応します。
14471423
14481424=begin original
14491425
14501426The behaviour of C<%-> is implemented via the
14511427L<Tie::Hash::NamedCapture> module.
14521428
14531429=end original
14541430
14551431C<%-> の振る舞いは L<Tie::Hash::NamedCapture> モジュールを使って
14561432実装されています。
14571433
14581434=begin original
14591435
14601436B<Note:> C<%-> and C<%+> are tied views into a common internal hash
14611437associated with the last successful regular expression. Therefore mixing
14621438iterative access to them via C<each> may have unpredictable results.
14631439Likewise, if the last successful match changes, then the results may be
14641440surprising.
14651441
14661442=end original
14671443
14681444B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の
14691445内部ハッシュと tie されたビューです。
14701446従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果と
14711447なります。
14721448同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。
14731449
14741450=item HANDLE->format_name(EXPR)
14751451
14761452=item $FORMAT_NAME
14771453
14781454=item $~
14791455X<$~> X<$FORMAT_NAME>
14801456
14811457=begin original
14821458
14831459The name of the current report format for the currently selected output
14841460channel. Default is the name of the filehandle. (Mnemonic: brother to
14851461C<$^>.)
14861462
14871463=end original
14881464
14891465その時点で選択されている出力チャネルの、その時点でのフォーマット名。
14901466デフォルトでは、ファイルハンドルと同名です。
14911467(記憶法: C<$^> の兄弟。)
14921468
14931469=item HANDLE->format_top_name(EXPR)
14941470
14951471=item $FORMAT_TOP_NAME
14961472
14971473=item $^
14981474X<$^> X<$FORMAT_TOP_NAME>
14991475
15001476=begin original
15011477
15021478The name of the current top-of-page format for the currently selected
15031479output channel. Default is the name of the filehandle with _TOP
15041480appended. (Mnemonic: points to top of page.)
15051481
15061482=end original
15071483
15081484その時点で選択されている出力チャネルの、その時点での
15091485ページ先頭フォーマット名。
15101486デフォルトでは、ファイルハンドル名に _TOP を続けたもの。
15111487(記憶法: ページの先頭へのポインタ。)
15121488
15131489=item IO::Handle->format_line_break_characters EXPR
15141490
15151491=item $FORMAT_LINE_BREAK_CHARACTERS
15161492
15171493=item $:
15181494X<$:> X<FORMAT_LINE_BREAK_CHARACTERS>
15191495
15201496=begin original
15211497
15221498The current set of characters after which a string may be broken to
15231499fill continuation fields (starting with ^) in a format. Default is
15241500S<" \n-">, to break on whitespace or hyphens. (Mnemonic: a "colon" in
15251501poetry is a part of a line.)
15261502
15271503=end original
15281504
15291505フォーマットの充填継続フィールド (^ で始まるもの) への
15301506文字列で行分割を許す文字集合。
15311507デフォルトは S<" \n-"> で空白か改行の後で行分割が可能となっています。
15321508(記憶法: 詩では「コロン」は、行の一部。)
15331509
15341510=item IO::Handle->format_formfeed EXPR
15351511
15361512=item $FORMAT_FORMFEED
15371513
15381514=item $^L
15391515X<$^L> X<$FORMAT_FORMFEED>
15401516
15411517=begin original
15421518
15431519What formats output as a form feed. Default is \f.
15441520
15451521=end original
15461522
15471523フォーマット出力で、改ページのために出力されるもの。
15481524デフォルトは \f。
15491525
15501526=item $ACCUMULATOR
15511527
15521528=item $^A
15531529X<$^A> X<$ACCUMULATOR>
15541530
15551531=begin original
15561532
15571533The current value of the write() accumulator for format() lines. A format
15581534contains formline() calls that put their result into C<$^A>. After
15591535calling its format, write() prints out the contents of C<$^A> and empties.
15601536So you never really see the contents of C<$^A> unless you call
15611537formline() yourself and then look at it. See L<perlform> and
15621538L<perlfunc/formline()>.
15631539
15641540=end original
15651541
15661542format() 行のための、その時点での write() アキュムレータの値。
15671543format には、C<$^A> に結果を残す、formline() 呼び出しが含まれます。
15681544自分のフォーマットを呼び出した後で、
15691545write() は C<$^A> の内容を出力してから消去します。
15701546したがって、自分で formline() を呼び出すのでなければ、
15711547C<$^A> の値が見えることはありません。
15721548L<perlform> と L<perlfunc/formline()> を参照してください。
15731549
15741550=item $CHILD_ERROR
15751551
15761552=item $?
15771553X<$?> X<$CHILD_ERROR>
15781554
15791555=begin original
15801556
15811557The status returned by the last pipe close, backtick (C<``>) command,
15821558successful call to wait() or waitpid(), or from the system()
15831559operator. This is just the 16-bit status word returned by the
15841560traditional Unix wait() system call (or else is made up to look like it). Thus, the
15851561exit value of the subprocess is really (C<<< $? >> 8 >>>), and
15861562C<$? & 127> gives which signal, if any, the process died from, and
15871563C<$? & 128> reports whether there was a core dump. (Mnemonic:
15881564similar to B<sh> and B<ksh>.)
15891565
15901566=end original
15911567
15921568最後に close したパイプ、バッククォート (C<``>) コマンド、
15931569成功した wait() または waitpid() 呼び出し、system() 演算子が返したステータス。
15941570このステータスワードは伝統的な Unix の wait() システムコールが返した
1595157116 ビットのステータス(またはそのように見えるもの)です。
15961572従ってサブプロセスの exit 値は、実際には (C<<< $? >> 8 >>>)
15971573で、C<$? & 127> は、もしあれば、そのプロセスを止めたシグナルで、
15981574C<$? & 128> はコアダンプがあるかどうかを示します。
15991575(記憶法: B<sh> や B<ksh> と同様。)
16001576
16011577=begin original
16021578
16031579Additionally, if the C<h_errno> variable is supported in C, its value
16041580is returned via $? if any C<gethost*()> function fails.
16051581
16061582=end original
16071583
16081584さらに、C で C<h_errno> 変数に対応している場合は、
16091585C<gethost*()> が失敗したときに $? を通して返されます。
16101586
16111587=begin original
16121588
16131589If you have installed a signal handler for C<SIGCHLD>, the
16141590value of C<$?> will usually be wrong outside that handler.
16151591
16161592=end original
16171593
16181594C<SIGCHLD> のシグナルハンドラを設定した場合、
16191595C<$?> の値は通常ハンドラの外側では正しくない値となります。
16201596
16211597=begin original
16221598
16231599Inside an C<END> subroutine C<$?> contains the value that is going to be
16241600given to C<exit()>. You can modify C<$?> in an C<END> subroutine to
16251601change the exit status of your program. For example:
16261602
16271603=end original
16281604
16291605C<END> サブルーチンの内側では C<$?> には C<exit()> に渡されようとしている
16301606値を含みます。
16311607プログラムの終了ステータスを変更するために、C<END> サブルーチン 内で
16321608C<$?> を変更できます。
16331609例えば:
16341610
16351611 END {
16361612 $? = 1 if $? == 255; # die would make it 255
16371613 }
16381614
16391615=begin original
16401616
16411617Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect the
16421618actual VMS exit status, instead of the default emulation of POSIX
16431619status; see L<perlvms/$?> for details.
16441620
16451621=end original
16461622
16471623VMS では、C<use vmsish 'status'> を指定すると、
16481624C<$?> はPOSIX ステータスをエミュレートしたものではなく、
16491625実際の VMS 終了ステータスを反映します; 詳細は L<perlvms/$?> を
16501626参照してください。
16511627
16521628=begin original
16531629
16541630Also see L<Error Indicators>.
16551631
16561632=end original
16571633
16581634L<Error Indicators> も参照して下さい。
16591635
16601636=item ${^CHILD_ERROR_NATIVE}
16611637X<$^CHILD_ERROR_NATIVE>
16621638
16631639=begin original
16641640
16651641The native status returned by the last pipe close, backtick (C<``>)
16661642command, successful call to wait() or waitpid(), or from the system()
16671643operator. On POSIX-like systems this value can be decoded with the
16681644WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG
16691645and WIFCONTINUED functions provided by the L<POSIX> module.
16701646
16711647=end original
16721648
16731649The native status returned by
16741650最後のパイプクローズ、逆クォート (C<``>) コマンド、wait() と waitpid() の
16751651成功した呼び出し、system() 演算子から返された、ネイティブなステータスです。
16761652POSIX 風システムでは、この値は L<POSIX> モジュールで提供される
16771653WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG,
16781654WIFCONTINUED 関数でデコードできます。
16791655
16801656=begin original
16811657
16821658Under VMS this reflects the actual VMS exit status; i.e. it is the same
16831659as $? when the pragma C<use vmsish 'status'> is in effect.
16841660
16851661=end original
16861662
16871663VMS ではこれは実際の VMS の終了ステータスを反映します;
16881664言い換えると、これは C<use vmsish 'status'> プラグマが有効なときの $? と
16891665同じです。
16901666
16911667=item ${^ENCODING}
16921668X<$^ENCODING>
16931669
16941670=begin original
16951671
16961672The I<object reference> to the Encode object that is used to convert
16971673the source code to Unicode. Thanks to this variable your perl script
16981674does not have to be written in UTF-8. Default is I<undef>. The direct
16991675manipulation of this variable is highly discouraged.
17001676
17011677=end original
17021678
17031679ソースコードを Unicode に変換するために使われる Encode オブジェクトへの
17041680I<オブジェクトリファレンス> 。
17051681この変数のおかげで、perl スクリプトを UTF-8 で書く必要がありません。
17061682デフォルトは I<undef> 。
17071683この変数を直接操作することはとても推奨できません。
17081684
17091685=item $OS_ERROR
17101686
17111687=item $ERRNO
17121688
17131689=item $!
17141690X<$!> X<$ERRNO> X<$OS_ERROR>
17151691
17161692=begin original
17171693
17181694If used numerically, yields the current value of the C C<errno>
17191695variable, or in other words, if a system or library call fails, it
17201696sets this variable. This means that the value of C<$!> is meaningful
17211697only I<immediately> after a B<failure>:
17221698
17231699=end original
17241700
17251701数値として使われると、その時点の C の C<errno> 変数の値が得られます;
17261702言い換えると、もしシステムコールやライブラリ呼び出しが失敗すると、
17271703この変数がセットされます。
17281704これは、C<$!> の値が意味を持つのは B<失敗> の I<直後> だけということを
17291705意味します。
17301706
1731 if (open my $fh, "<", $filename) {
1707 if (open(FH, $filename)) {
17321708 # Here $! is meaningless.
17331709 ...
17341710 } else {
17351711 # ONLY here is $! meaningful.
17361712 ...
17371713 # Already here $! might be meaningless.
17381714 }
17391715 # Since here we might have either success or failure,
17401716 # here $! is meaningless.
17411717
17421718=begin original
17431719
17441720In the above I<meaningless> stands for anything: zero, non-zero,
17451721C<undef>. A successful system or library call does B<not> set
17461722the variable to zero.
17471723
17481724=end original
17491725
17501726上記の I<meaningless> は何でもあり得ます: 0、非 0、C<undef>。
17511727システムコールやライブラリ呼び出しが成功した場合は、この変数は 0 に
17521728セット B<されません>。
17531729
17541730=begin original
17551731
17561732If used as a string, yields the corresponding system error string.
17571733You can assign a number to C<$!> to set I<errno> if, for instance,
17581734you want C<"$!"> to return the string for error I<n>, or you want
17591735to set the exit value for the die() operator. (Mnemonic: What just
17601736went bang?)
17611737
17621738=end original
17631739
17641740文字列として使われると、対応するシステムエラーのメッセージ文字列が得られます。
17651741たとえば、C<$!> にエラーの文字列を返して欲しいならば、あるいは、
17661742die() 演算子の exit 値を設定するために、I<errno> を設定するため
17671743C<$!> へ代入を行なうことが可能です。
17681744(記憶法: 何が bang(!) したか。)
17691745
17701746=begin original
17711747
17721748Also see L<Error Indicators>.
17731749
17741750=end original
17751751
17761752L<Error Indicators> も参照して下さい。
17771753
17781754=item %OS_ERROR
17791755
17801756=item %ERRNO
17811757
17821758=item %!
17831759X<%!>
17841760
17851761=begin original
17861762
17871763Each element of C<%!> has a true value only if C<$!> is set to that
17881764value. For example, C<$!{ENOENT}> is true if and only if the current
17891765value of C<$!> is C<ENOENT>; that is, if the most recent error was
17901766"No such file or directory" (or its moral equivalent: not all operating
17911767systems give that exact error, and certainly not all languages).
17921768To check if a particular key is meaningful on your system, use
17931769C<exists $!{the_key}>; for a list of legal keys, use C<keys %!>.
17941770See L<Errno> for more information, and also see above for the
17951771validity of C<$!>.
17961772
17971773=end original
17981774
17991775C<%!> の各要素は、C<$!> がその値にセットされている場合にのみ真の値を
18001776持ちます。
18011777例えば、C<$!{ENOENT}> は、現在の C<$!> の値が C<ENOENT> の場合にのみ
18021778真となります; これは、最近のエラーが
18031779"No such file or directory" (あるいは倫理的に等価なもの: 全ての OS が正確に
18041780同じエラーを出すわけではないですし、全ての言語で出るわけでもありません) の
18051781場合です。
18061782あなたのシステムで特定のキーが意味があるかどうかを調べるには、
18071783C<exists $!{the_key}> を使ってください; 有効なキーのリストを得るには、
18081784C<keys %!> としてください。
18091785さらなる情報と、C<$!> のバラエティに関しては、L<Errno> を参照してください。
18101786
18111787=item $EXTENDED_OS_ERROR
18121788
18131789=item $^E
18141790X<$^E> X<$EXTENDED_OS_ERROR>
18151791
18161792=begin original
18171793
18181794Error information specific to the current operating system. At
18191795the moment, this differs from C<$!> under only VMS, OS/2, and Win32
18201796(and for MacPerl). On all other platforms, C<$^E> is always just
18211797the same as C<$!>.
18221798
18231799=end original
18241800
18251801現在のオペレーティングシステムに特化したエラー情報です。
18261802現在のところ、VMS, OS/2, Win32 (と MacPerl) のみで
18271803C<$!> と異なる値をもちます。
18281804その他のプラットフォームでは、C<$^E> はいつも C<$!> と同じです。
18291805
18301806=begin original
18311807
18321808Under VMS, C<$^E> provides the VMS status value from the last
18331809system error. This is more specific information about the last
18341810system error than that provided by C<$!>. This is particularly
18351811important when C<$!> is set to B<EVMSERR>.
18361812
18371813=end original
18381814
18391815VMS では、C<$^E> は最後のシステムエラーの VMS ステータス値です。
18401816これは、最後のシステムエラーについて C<$!> で提供されるものより
18411817具体的な情報を示します。
18421818これは特に C<$!> が B<EVMSERR> にセットされた場合に重要です。
18431819
18441820=begin original
18451821
18461822Under OS/2, C<$^E> is set to the error code of the last call to
18471823OS/2 API either via CRT, or directly from perl.
18481824
18491825=end original
18501826
18511827OS/2 では、C<$^E> は CRT 経由、または Perl から直接呼び出された
18521828最後の OS/2 API のエラーコードがセットされます。
18531829
18541830=begin original
18551831
18561832Under Win32, C<$^E> always returns the last error information
18571833reported by the Win32 call C<GetLastError()> which describes
18581834the last error from within the Win32 API. Most Win32-specific
18591835code will report errors via C<$^E>. ANSI C and Unix-like calls
18601836set C<errno> and so most portable Perl code will report errors
18611837via C<$!>.
18621838
18631839=end original
18641840
18651841Win32 では、C<$^E> は Win32 API での最後のエラーの内容を返す
18661842C<GetLastError()> Win32 呼び出しで報告される最新のエラー情報を
18671843返します。
18681844ほとんどの Win32 固有のコードはエラーを C<$^E> 経由で返します。
18691845ANSI C と Unix 風の呼び出しは C<errno> をセットするので、
18701846ほとんどの移植性のある Perl コードは C<$!> 経由で
18711847エラーを報告します。
18721848
18731849=begin original
18741850
18751851Caveats mentioned in the description of C<$!> generally apply to
18761852C<$^E>, also. (Mnemonic: Extra error explanation.)
18771853
18781854=end original
18791855
18801856C<$!> の説明で触れた問題点は一般的に C<$^E> にも適用されます。
18811857(記憶法: 追加の(Extra)エラーの説明。)
18821858
18831859=begin original
18841860
18851861Also see L<Error Indicators>.
18861862
18871863=end original
18881864
18891865L<Error Indicators> も参照して下さい。
18901866
18911867=item $EVAL_ERROR
18921868
18931869=item $@
18941870X<$@> X<$EVAL_ERROR>
18951871
18961872=begin original
18971873
18981874The Perl syntax error message from the last eval() operator.
18991875If $@ is the null string, the last eval() parsed and executed
19001876correctly (although the operations you invoked may have failed in the
19011877normal fashion). (Mnemonic: Where was the syntax error "at"?)
19021878
19031879=end original
19041880
19051881最後の eval() 操作子による Perl の構文エラーメッセージです。
19061882$@ が空文字列であれば、最後の eval() が正常に
19071883解析され、実行されたことになります (が、実行した演算子が、
19081884通常の意味で失敗しているかもしれません)。
19091885(記憶法: どこで ("at" where) 構文エラーが起ったか。)
19101886
19111887=begin original
19121888
19131889Warning messages are not collected in this variable. You can,
19141890however, set up a routine to process warnings by setting C<$SIG{__WARN__}>
19151891as described below.
19161892
19171893=end original
19181894
19191895警告メッセージはこの変数に入りません。
19201896しかし、後述する C<$SIG{__WARN__}> にセットすることで
19211897警告を処理するルーチンを設定できます。
19221898
19231899=begin original
19241900
19251901Also see L<Error Indicators>.
19261902
19271903=end original
19281904
19291905L<Error Indicators> も参照して下さい。
19301906
19311907=item $PROCESS_ID
19321908
19331909=item $PID
19341910
19351911=item $$
19361912X<$$> X<$PID> X<$PROCESS_ID>
19371913
19381914=begin original
19391915
19401916The process number of the Perl running this script. You should
19411917consider this variable read-only, although it will be altered
19421918across fork() calls. (Mnemonic: same as shells.)
19431919
19441920=end original
19451921
19461922スクリプトを実行している Perl のプロセス番号です。
19471923この変数は read-only と考えるべきですが、
19481924fork() 呼び出しによって値は変わります。
19491925(記憶法: シェルと同じ。)
19501926
19511927=begin original
19521928
19531929Note for Linux users: on Linux, the C functions C<getpid()> and
19541930C<getppid()> return different values from different threads. In order to
19551931be portable, this behavior is not reflected by C<$$>, whose value remains
19561932consistent across threads. If you want to call the underlying C<getpid()>,
19571933you may use the CPAN module C<Linux::Pid>.
19581934
19591935=end original
19601936
19611937Linux ユーザーへの注意: Linux では、C 関数 C<getpid()> と C<getppid()> は
19621938スレッドが異なると異なった値を返します。
19631939移植性のために、この振る舞いは C<$$> には反映されず、この値はスレッド間で
19641940一貫しています。
19651941もし内在する C<getpid()> を呼び出したい場合は、CPAN モジュール
19661942C<Linux::Pid> が使えます。
19671943
19681944=item $REAL_USER_ID
19691945
19701946=item $UID
19711947
19721948=item $<
19731949X<< $< >> X<$UID> X<$REAL_USER_ID>
19741950
19751951=begin original
19761952
19771953The real uid of this process. (Mnemonic: it's the uid you came I<from>,
19781954if you're running setuid.) You can change both the real uid and
19791955the effective uid at the same time by using POSIX::setuid(). Since
19801956changes to $< require a system call, check $! after a change attempt to
19811957detect any possible errors.
19821958
19831959=end original
19841960
19851961本プロセスの実 uid を示します。
19861962(記憶法: setuid で実行中であれば、そこ「から」来た uid です。)
19871963POSIX::setuid() を使って、実効 UID と実 UID を同時に変更できます。
19881964$> を変更にはシステムコールが必要なので、起こりうるエラーを検出するために
19891965$! のチェックが必要です。
19901966
19911967=item $EFFECTIVE_USER_ID
19921968
19931969=item $EUID
19941970
19951971=item $>
19961972X<< $> >> X<$EUID> X<$EFFECTIVE_USER_ID>
19971973
19981974=begin original
19991975
20001976The effective uid of this process. Example:
20011977
20021978=end original
20031979
20041980本プロセスの実効 uid を示します。
20051981例:
20061982
20071983 $< = $>; # set real to effective uid
20081984 ($<,$>) = ($>,$<); # swap real and effective uid
20091985
20101986=begin original
20111987
20121988You can change both the effective uid and the real uid at the same
20131989time by using POSIX::setuid(). Changes to $> require a check to $!
20141990to detect any possible errors after an attempted change.
20151991
20161992=end original
20171993
20181994POSIX::setuid() を使って、実効 UID と実 UID を同時に変更できます。
20191995$> を変更した場合は、変更時に起こりうるエラーを検出するために $! の
20201996チェックが必要です。
20211997
20221998=begin original
20231999
20242000(Mnemonic: it's the uid you went I<to>, if you're running setuid.)
20252001C<< $< >> and C<< $> >> can be swapped only on machines
20262002supporting setreuid().
20272003
20282004=end original
20292005
20302006(記憶法: setuid で実行中であれば、そこ「へ」行く uidです。)
20312007C<< $< >> と C<< $> >> の交換は、setreuid() をサポートしている
20322008マシンでのみ可能です。
20332009
20342010=item $REAL_GROUP_ID
20352011
20362012=item $GID
20372013
20382014=item $(
20392015X<$(> X<$GID> X<$REAL_GROUP_ID>
20402016
20412017=begin original
20422018
20432019The real gid of this process. If you are on a machine that supports
20442020membership in multiple groups simultaneously, gives a space separated
20452021list of groups you are in. The first number is the one returned by
20462022getgid(), and the subsequent ones by getgroups(), one of which may be
20472023the same as the first number.
20482024
20492025=end original
20502026
20512027本プロセスの実 gid を示します。
20522028同時に複数のグループに所属できるマシンでは、所属するグループをスペースで
20532029区切ったリストが得られます。
20542030最初の数値は、getgid() で返されるものです。
20552031その後に getgroups() が返す値が続き、その中の 1 つは、
20562032最初の値と同じかもしれません。
20572033
20582034=begin original
20592035
20602036However, a value assigned to C<$(> must be a single number used to
20612037set the real gid. So the value given by C<$(> should I<not> be assigned
20622038back to C<$(> without being forced numeric, such as by adding zero. Note
20632039that this is different to the effective gid (C<$)>) which does take a
20642040list.
20652041
20662042=end original
20672043
20682044しかし、C<$(> に代入された値は実際の gid に設定された値の
20692045一つでなければなりません。
20702046従って、 C<$(> で与えられた値はゼロを足すことによって
20712047数値化することなく C<$(> に書き戻すべきではありません。
20722048これはリストが得られる実行 GID (C<$)>) とは違うことに注意してください。
20732049
20742050=begin original
20752051
20762052You can change both the real gid and the effective gid at the same
20772053time by using POSIX::setgid(). Changes to $( require a check to $!
20782054to detect any possible errors after an attempted change.
20792055
20802056=end original
20812057
20822058POSIX::setgid() を使って、実 GID と実効 GID の両方を同時に変更できます。
20832059$( を変更した場合は、変更しようとしたときに起こりうるエラーを検出するために
20842060$! をチェックする必要があります。
20852061
20862062=begin original
20872063
20882064(Mnemonic: parentheses are used to I<group> things. The real gid is the
20892065group you I<left>, if you're running setgid.)
20902066
20912067=end original
20922068
20932069(記憶法: 括弧は、I<グループ化>に使われます。
20942070setgid で実行中であれば、実 gid は I<left> した、
20952071つまり離れたグループです。)
20962072
20972073=item $EFFECTIVE_GROUP_ID
20982074
20992075=item $EGID
21002076
21012077=item $)
21022078X<$)> X<$EGID> X<$EFFECTIVE_GROUP_ID>
21032079
21042080=begin original
21052081
21062082The effective gid of this process. If you are on a machine that
21072083supports membership in multiple groups simultaneously, gives a space
21082084separated list of groups you are in. The first number is the one
21092085returned by getegid(), and the subsequent ones by getgroups(), one of
21102086which may be the same as the first number.
21112087
21122088=end original
21132089
21142090本プロセスの実効 gid を示します。
21152091同時に複数のグループに所属できるマシンでは、
21162092所属するグループをスペースで区切ったリストが得られます。
21172093最初の数値は、getegid() で返されるものです。
21182094その後に getgroups()が返す値が続き、その中の 1 つは、
21192095最初の値と同じかもしれません。
21202096
21212097=begin original
21222098
21232099Similarly, a value assigned to C<$)> must also be a space-separated
21242100list of numbers. The first number sets the effective gid, and
21252101the rest (if any) are passed to setgroups(). To get the effect of an
21262102empty list for setgroups(), just repeat the new effective gid; that is,
21272103to force an effective gid of 5 and an effectively empty setgroups()
21282104list, say C< $) = "5 5" >.
21292105
21302106=end original
21312107
21322108同様に、C<$)> へ代入する値はスペースで区切られた数値の
21332109リストでなければなりません。
21342110最初の数値は実効 gid を設定し、残りの数値は(もしあれば) setgroups() に
21352111渡されます。
21362112setgroups() に空リストを渡したい場合は、単に新しい実効 gid を
21372113繰り返してください。
21382114つまり、実効 gid を 5 にして、setgroups() に空リストを渡したい場合は、
21392115C< $) = "5 5" > としてください。
21402116
21412117=begin original
21422118
21432119You can change both the effective gid and the real gid at the same
21442120time by using POSIX::setgid() (use only a single numeric argument).
21452121Changes to $) require a check to $! to detect any possible errors
21462122after an attempted change.
21472123
21482124=end original
21492125
21502126POSIX::setgid() を使って、実効 GID と実 GID を同時に変更できます。
21512127(1 つの数値引数だけが使えます)。
21522128$) を変更した場合は、変更時に起こりうるエラーを検出するために $! の
21532129チェックが必要です。
21542130
21552131=begin original
21562132
21572133(Mnemonic: parentheses are used to I<group> things. The effective gid
21582134is the group that's I<right> for you, if you're running setgid.)
21592135
21602136=end original
21612137
21622138(記憶法: 括弧は、I<グループ化>に使われます。
21632139setgid で実行中であれば、実効 gid は right な、つまり正しいグループです。)
21642140
21652141=begin original
21662142
21672143C<< $< >>, C<< $> >>, C<$(> and C<$)> can be set only on
21682144machines that support the corresponding I<set[re][ug]id()> routine. C<$(>
21692145and C<$)> can be swapped only on machines supporting setregid().
21702146
21712147=end original
21722148
21732149C<< $< >>, C<< $> >>, C<$(>, C<$)> は、実行するマシンで、
21742150対応する I<set[re][ug]id()> ルーティンがサポートされているときにのみ
21752151設定可能です。
21762152C<$(> と C<$)> の交換は、
21772153setregid() がサポートされているマシンでのみ可能です。
21782154
21792155=item $PROGRAM_NAME
21802156
21812157=item $0
21822158X<$0> X<$PROGRAM_NAME>
21832159
21842160=begin original
21852161
21862162Contains the name of the program being executed.
21872163
21882164=end original
21892165
21902166実行されているプログラムの名前を示します。
21912167
21922168=begin original
21932169
21942170On some (read: not all) operating systems assigning to C<$0> modifies
21952171the argument area that the C<ps> program sees. On some platforms you
21962172may have to use special C<ps> options or a different C<ps> to see the
21972173changes. Modifying the $0 is more useful as a way of indicating the
21982174current program state than it is for hiding the program you're
21992175running. (Mnemonic: same as B<sh> and B<ksh>.)
22002176
22012177=end original
22022178
22032179C<$0> に代入を行なうことで B<ps>) プログラムが覗く、
22042180引数エリアを修正できるシステムもあります(全てではありません)。
22052181$0 の修正は、実行しているプログラムを隠すよりは、
22062182実行中のプログラムの状態を表示するときに、使うとよいでしょう。
22072183(記憶法: B<sh> や B<ksh> と同じ。)
22082184
22092185=begin original
22102186
22112187Note that there are platform specific limitations on the maximum
22122188length of C<$0>. In the most extreme case it may be limited to the
22132189space occupied by the original C<$0>.
22142190
22152191=end original
22162192
22172193C<$0> の最大長にはプラットフォーム固有の制限があることに注意してください。
22182194最も極端な場合では、元の C<$0> で占められているサイズに制限されます。
22192195
22202196=begin original
22212197
22222198In some platforms there may be arbitrary amount of padding, for
22232199example space characters, after the modified name as shown by C<ps>.
22242200In some platforms this padding may extend all the way to the original
22252201length of the argument area, no matter what you do (this is the case
22262202for example with Linux 2.2).
22272203
22282204=end original
22292205
22302206プラットフォームによっては、任意の量のパッディングがある場合があります;
22312207例えば、C<ps> で見られる修正された名前の後の空白文字です。
22322208プラットフォームによっては、このパッディングは、あなたが何をしたかに
22332209関わらず、元の引数のエリア全体に拡張されるものもあります
22342210(例えば、これは Linux 2.2 の場合です)。
22352211
22362212=begin original
22372213
22382214Note for BSD users: setting C<$0> does not completely remove "perl"
22392215from the ps(1) output. For example, setting C<$0> to C<"foobar"> may
22402216result in C<"perl: foobar (perl)"> (whether both the C<"perl: "> prefix
22412217and the " (perl)" suffix are shown depends on your exact BSD variant
22422218and version). This is an operating system feature, Perl cannot help it.
22432219
22442220=end original
22452221
22462222BSD ユーザーへの注意: C<$0> に値をセットしても、ps(1) の出力から
22472223完全に "perl" の文字列は取り除かれません。
22482224例えば、C<$0> に C<"foobar"> と設定すると、C<"perl: foobar (perl)"> という
22492225結果になります
22502226(C<"perl: "> 接頭辞と" (perl)" 接尾辞が表示されるかどうかは 、正確な
22512227BSD の種類とバージョンに依存します)。
22522228これはオペレーティングシステムの機能で、Perl は何もできません。
22532229
22542230=begin original
22552231
22562232In multithreaded scripts Perl coordinates the threads so that any
22572233thread may modify its copy of the C<$0> and the change becomes visible
22582234to ps(1) (assuming the operating system plays along). Note that
22592235the view of C<$0> the other threads have will not change since they
22602236have their own copies of it.
22612237
22622238=end original
22632239
22642240マルチスレッドスクリプトでは、どのスレッドも自身の C<$0> のコピーを
22652241変更できて、その変更が(OS が対応しているとして) ps(1) で見えるように、
22662242Perl がスレッドを調整します。
22672243他のスレッドが持っている C<$0> の見え方は(各自が自身のコピーを
22682244持っているので)変わらないことに注意してください。
22692245
2270=begin original
2271
2272If the program has been given to perl via the switches C<-e> or C<-E>,
2273C<$0> will contain the string C<"-e">.
2274
2275=end original
2276
2277プログラムが perl に C<-e> または C<-E> オプション経由で与えられた場合、
2278C<$0> には文字列 C<"-e"> を含みます。
2279
22802246=item $[
22812247X<$[>
22822248
22832249=begin original
22842250
22852251The index of the first element in an array, and of the first character
22862252in a substring. Default is 0, but you could theoretically set it
22872253to 1 to make Perl behave more like B<awk> (or Fortran) when
22882254subscripting and when evaluating the index() and substr() functions.
22892255(Mnemonic: [ begins subscripts.)
22902256
22912257=end original
22922258
22932259配列の最初の要素や、文字列の最初の文字のインデックスを
22942260示します。
22952261デフォルトは 0 ですが、理論的には、index() 関数や
22962262substr() 関数を評価するときに、Perl の動作をより B<awk>
22972263(や Fortran) に近づけるため、1 に設定することもできます。
22982264(記憶法: [ は添え字付けの始め。)
22992265
23002266=begin original
23012267
23022268As of release 5 of Perl, assignment to C<$[> is treated as a compiler
23032269directive, and cannot influence the behavior of any other file.
2304(That's why you can only assign compile-time constants to it.) Its
2270(That's why you can only assign compile-time constants to it.)
2305use is deprecated, and by default will trigger a warning.
2271Its use is highly discouraged.
23062272
23072273=end original
23082274
23092275Perl 5 からは C<$[> への代入は、コンパイラ指示子として扱われ、
23102276他のファイルの動作に影響を与えることがなくなりました。
23112277(これが、コンパイル時定数しか代入できない理由です。)
2312この変数の使用非推奨、デフォルトでは警告が出ます
2278この変数はできるだけ使わないようにしてください
23132279
23142280=begin original
23152281
23162282Note that, unlike other compile-time directives (such as L<strict>),
23172283assignment to C<$[> can be seen from outer lexical scopes in the same file.
23182284However, you can use local() on it to strictly bind its value to a
23192285lexical block.
23202286
23212287=end original
23222288
23232289(L<strict> のような) その他のコンパイル時指示子と違って、C<$[> への代入は、
23242290同じファイルのより外側のレキシカルスコープからも見えることに注意してください。
23252291但し、これに local() を使うことでこの値をレキシカルブロック内に束縛できます。
23262292
23272293=item $]
23282294X<$]>
23292295
23302296=begin original
23312297
23322298The version + patchlevel / 1000 of the Perl interpreter. This variable
23332299can be used to determine whether the Perl interpreter executing a
23342300script is in the right range of versions. (Mnemonic: Is this version
23352301of perl in the right bracket?) Example:
23362302
23372303=end original
23382304
23392305Perl インタプリタの version + patchlevel / 1000 が返されます。
23402306スクリプトの最初で、そのスクリプトを実行しているインタプリタのバージョンが
23412307適切な範囲内にあるかを調べる、といったことができます。
23422308(記憶法: Perl のバージョンは、正しい範囲 (right bracket) にあるか。)
23432309例:
23442310
23452311 warn "No checksumming!\n" if $] < 3.019;
23462312
23472313=begin original
23482314
23492315See also the documentation of C<use VERSION> and C<require VERSION>
23502316for a convenient way to fail if the running Perl interpreter is too old.
23512317
23522318=end original
23532319
23542320実行する Perl インタプリタが古すぎる場合に終了する便利な方法に
23552321ついては C<use VERSION> と C<require VERSION> のドキュメントも
23562322参照して下さい。
23572323
23582324=begin original
23592325
23602326The floating point representation can sometimes lead to inaccurate
23612327numeric comparisons. See C<$^V> for a more modern representation of
23622328the Perl version that allows accurate string comparisons.
23632329
23642330=end original
23652331
23662332浮動小数点表現は数値比較が不正確になることがあります。
23672333文字列比較が使える新しい Perl バージョンの表現方法である C<$^V> を
23682334参照して下さい。
23692335
23702336=item $COMPILING
23712337
23722338=item $^C
23732339X<$^C> X<$COMPILING>
23742340
23752341=begin original
23762342
23772343The current value of the flag associated with the B<-c> switch.
23782344Mainly of use with B<-MO=...> to allow code to alter its behavior
23792345when being compiled, such as for example to AUTOLOAD at compile
23802346time rather than normal, deferred loading. Setting
23812347C<$^C = 1> is similar to calling C<B::minus_c>.
23822348
23832349=end original
23842350
23852351B<-c> スイッチに関連付けられた現在の値です。
23862352主に B<-MO=...> と共に用いられ、例えば AUTOLOAD を通常の遅延ロードでは
23872353なくコンパイル時に実行するといった、コンパイル時の振る舞いを
23882354変えるために用います。
23892355C<$^C = 1> に設定することは C<B::minus_c> を呼び出すのと似ています。
23902356
23912357=item $DEBUGGING
23922358
23932359=item $^D
23942360X<$^D> X<$DEBUGGING>
23952361
23962362=begin original
23972363
23982364The current value of the debugging flags. (Mnemonic: value of B<-D>
23992365switch.) May be read or set. Like its command-line equivalent, you can use
24002366numeric or symbolic values, eg C<$^D = 10> or C<$^D = "st">.
24012367
24022368=end original
24032369
24042370デバッグフラグの現在の値を示します。
24052371(記憶法: B<-D> スイッチの値。)
24062372読み書き可能です。
24072373コマンドラインによる等価な機能と同様に、数値とシンボル値が使えます
24082374(例: C<$^D = 10> または C<$^D = "st">)。
24092375
24102376=item ${^RE_DEBUG_FLAGS}
24112377
24122378=begin original
24132379
24142380The current value of the regex debugging flags. Set to 0 for no debug output
24152381even when the re 'debug' module is loaded. See L<re> for details.
24162382
24172383=end original
24182384
24192385正規表現デバッグフラグの現在の値です。
242023860 をセットすると、re 'debug' モジュールが読み込まれていても
24212387デバッグ出力を行いません。
24222388詳細については L<re> を参照してください。
24232389
24242390=item ${^RE_TRIE_MAXBUF}
24252391
24262392=begin original
24272393
24282394Controls how certain regex optimisations are applied and how much memory they
24292395utilize. This value by default is 65536 which corresponds to a 512kB temporary
24302396cache. Set this to a higher value to trade memory for speed when matching
24312397large alternations. Set it to a lower value if you want the optimisations to
24322398be as conservative of memory as possible but still occur, and set it to a
24332399negative value to prevent the optimisation and conserve the most memory.
24342400Under normal situations this variable should be of no interest to you.
24352401
24362402=end original
24372403
24382404どれくらい正規表現の最適化を行い、どれくらいのメモリを利用するかを
24392405制御します。
24402406デフォルトではこの値は 65536 で、512kB の一時キャッシュに相当します。
24412407この値を大きくすると、大きなものとマッチングするときに速度を重視して
24422408多くのメモリを使います。
24432409もしできるだけ保守的なメモリ消費をするけれども使うこともある、というように
24442410最適化したい場合は小さい値を設定します; 負の値を設定すると最適化は行わず、
24452411最大限メモリを節約します。
24462412通常の状況では、この変数はあなたの興味を引くものではないでしょう。
24472413
24482414=item $SYSTEM_FD_MAX
24492415
24502416=item $^F
24512417X<$^F> X<$SYSTEM_FD_MAX>
24522418
24532419=begin original
24542420
24552421The maximum system file descriptor, ordinarily 2. System file
24562422descriptors are passed to exec()ed processes, while higher file
24572423descriptors are not. Also, during an open(), system file descriptors are
24582424preserved even if the open() fails. (Ordinary file descriptors are
24592425closed before the open() is attempted.) The close-on-exec
24602426status of a file descriptor will be decided according to the value of
24612427C<$^F> when the corresponding file, pipe, or socket was opened, not the
24622428time of the exec().
24632429
24642430=end original
24652431
24662432システムが使用するファイル記述子の最大値を示し、通常は 2 です。
24672433システムファイル記述子は、exec() されたプロセスに渡されますが、
24682434それ以降のファイル記述子は渡されません。
24692435また、open() の実行中は、システムファイル記述子は、
24702436たとえ open() が失敗しても、保存されます。
24712437(通常のファイル記述子は、open() が実行される前にクローズされます。)
24722438ファイル記述子の close-on-exec のステータスは、exec() 時ではなく、
24732439対応するファイル、パイプソケットの open 時の C<$^F> の値によって
24742440決められます。
24752441
24762442=item $^H
24772443
24782444=begin original
24792445
24802446WARNING: This variable is strictly for internal use only. Its availability,
24812447behavior, and contents are subject to change without notice.
24822448
24832449=end original
24842450
24852451警告: この変数は厳密に内部使用に限定されます。
24862452その可用性、挙動、内容は告知なく変更される可能性があります。
24872453
24882454=begin original
24892455
24902456This variable contains compile-time hints for the Perl interpreter. At the
24912457end of compilation of a BLOCK the value of this variable is restored to the
24922458value when the interpreter started to compile the BLOCK.
24932459
24942460=end original
24952461
24962462この変数には Perl インタプリタのコンパイル時のヒントが入ります。
24972463BLOCK のコンパイル終了時に、この変数の値は
24982464インタプリタが BLOCK のコンパイルを開始した時の値に戻されます。
24992465
25002466=begin original
25012467
25022468When perl begins to parse any block construct that provides a lexical scope
25032469(e.g., eval body, required file, subroutine body, loop body, or conditional
25042470block), the existing value of $^H is saved, but its value is left unchanged.
25052471When the compilation of the block is completed, it regains the saved value.
25062472Between the points where its value is saved and restored, code that
25072473executes within BEGIN blocks is free to change the value of $^H.
25082474
25092475=end original
25102476
25112477Perl がレキシカルスコープを持つブロック構造(eval の中身、required された
25122478ファイル、サブルーチンの中身、loop の中身、条件付きブロック)の
25132479パーズを開始するとき、現在の $^H の値は保存されますが、
25142480値は変更されません。
25152481ブロックのコンパイルが終わると、保存された値が戻されます。
25162482値の保存と回復の間の地点で、
25172483BEGIN ブロックの中で実行されるコードは自由に
25182484$^H の値を変更できます。
25192485
25202486=begin original
25212487
25222488This behavior provides the semantic of lexical scoping, and is used in,
25232489for instance, the C<use strict> pragma.
25242490
25252491=end original
25262492
25272493この振る舞いはレキシカルスコープを持ち、その中で使えます。
25282494例としては C<use strict> があります。
25292495
25302496=begin original
25312497
25322498The contents should be an integer; different bits of it are used for
25332499different pragmatic flags. Here's an example:
25342500
25352501=end original
25362502
25372503内容は整数であるべきです。
25382504ビット毎に異なるプラグマフラグとして使われます。以下は例です:
25392505
25402506 sub add_100 { $^H |= 0x100 }
25412507
25422508 sub foo {
25432509 BEGIN { add_100() }
25442510 bar->baz($boon);
25452511 }
25462512
25472513=begin original
25482514
25492515Consider what happens during execution of the BEGIN block. At this point
25502516the BEGIN block has already been compiled, but the body of foo() is still
25512517being compiled. The new value of $^H will therefore be visible only while
25522518the body of foo() is being compiled.
25532519
25542520=end original
25552521
25562522BEGIN ブロックの実行中に起こることを考えてみます。
25572523この時点で BEGIN ブロックは既にコンパイルされていますが、
25582524foo() の中身はまだコンパイル中です。
25592525従って $^H の新しい値は foo() の中身がコンパイル中にのみ
25602526見ることが出来ます。
25612527
25622528=begin original
25632529
25642530Substitution of the above BEGIN block with:
25652531
25662532=end original
25672533
25682534上記の BEGIN ブロックを以下のように変更すると:
25692535
25702536 BEGIN { require strict; strict->import('vars') }
25712537
25722538=begin original
25732539
25742540demonstrates how C<use strict 'vars'> is implemented. Here's a conditional
25752541version of the same lexical pragma:
25762542
25772543=end original
25782544
25792545どのように C<use strict 'vars'> が実装されているかがわかります。
25802546以下は同じレキシカルプラグマの条件付き版です:
25812547
25822548 BEGIN { require strict; strict->import('vars') if $condition }
25832549
25842550=item %^H
25852551
25862552=begin original
25872553
25882554The %^H hash provides the same scoping semantic as $^H. This makes it
25892555useful for implementation of lexically scoped pragmas. See L<perlpragma>.
25902556
25912557=end original
25922558
25932559%^H ハッシュは $^H と同じスコープを持ちます。
25942560これはレキシカルスコープを持つプラグマを実装するのに便利です。
25952561L<perlpragma> を参照してください。
25962562
25972563=item $INPLACE_EDIT
25982564
25992565=item $^I
26002566X<$^I> X<$INPLACE_EDIT>
26012567
26022568=begin original
26032569
26042570The current value of the inplace-edit extension. Use C<undef> to disable
26052571inplace editing. (Mnemonic: value of B<-i> switch.)
26062572
26072573=end original
26082574
26092575置き換え編集の拡張子の値を示します。
26102576置き換え編集を禁止するためには、C<undef> を設定します。
26112577(記憶法: B<-i> スイッチの値。)
26122578
26132579=item $^M
26142580X<$^M>
26152581
26162582=begin original
26172583
26182584By default, running out of memory is an untrappable, fatal error.
26192585However, if suitably built, Perl can use the contents of C<$^M>
26202586as an emergency memory pool after die()ing. Suppose that your Perl
26212587were compiled with C<-DPERL_EMERGENCY_SBRK> and used Perl's malloc.
26222588Then
26232589
26242590=end original
26252591
26262592デフォルトでは、メモリ不足はトラップできない致命的エラーとなります。
26272593しかし、もし適切に構築されていれば、Perl は C<$^M> の中身を
26282594die() した後の緊急用メモリとして使えます。
26292595Perl が C<-DPERL_EMERGENCY_SBRK> 付きでコンパイルされ、
26302596Perl の malloc を使うと仮定します。そして、
26312597
26322598 $^M = 'a' x (1 << 16);
26332599
26342600=begin original
26352601
26362602would allocate a 64K buffer for use in an emergency. See the
26372603F<INSTALL> file in the Perl distribution for information on how to
26382604add custom C compilation flags when compiling perl. To discourage casual
26392605use of this advanced feature, there is no L<English|English> long name for
26402606this variable.
26412607
26422608=end original
26432609
26442610とすると緊急用の 64K のバッファを割り当てます。
26452611perl をコンパイルするときに独自の C コンパイルフラグを追加する
26462612方法についての情報は、Perl 配布パッケージに含まれている
26472613F<INSTALL> ファイルを参照して下さい。
26482614この拡張機能を気軽に使えないようにするために、
26492615この変数には L<English|English> の長い名前はありません。
26502616
26512617=item $OSNAME
26522618
26532619=item $^O
26542620X<$^O> X<$OSNAME>
26552621
26562622=begin original
26572623
26582624The name of the operating system under which this copy of Perl was
26592625built, as determined during the configuration process. The value
26602626is identical to C<$Config{'osname'}>. See also L<Config> and the
26612627B<-V> command-line switch documented in L<perlrun>.
26622628
26632629=end original
26642630
26652631この Perl が構築されたオペレーティングシステムの名前です。
26662632これは設定プロセス中に決定されます。
26672633この値は C<$Config{'osname'}> と同じです。
26682634L<Config> と、L<perlrun> でドキュメント化されている
26692635B<-V> コマンドラインスイッチも参照して下さい。
26702636
26712637=begin original
26722638
26732639In Windows platforms, $^O is not very helpful: since it is always
26742640C<MSWin32>, it doesn't tell the difference between
2675264195/98/ME/NT/2000/XP/CE/.NET. Use Win32::GetOSName() or
26762642Win32::GetOSVersion() (see L<Win32> and L<perlport>) to distinguish
26772643between the variants.
26782644
26792645=end original
26802646
26812647Windows プラットフォームでは、$^O はあまり役に立ちません: これは常に
26822648C<MSWin32> となり、95/98/ME/NT/2000/XP/CE/.NET の違いを示していないからです。
26832649これらを区別するためには、Win32::GetOSName() や Win32::GetOSVersion() を
26842650使ってください (L<Win32> と L<perlport> を参照してください)。
26852651
26862652=item ${^OPEN}
26872653
26882654=begin original
26892655
26902656An internal variable used by PerlIO. A string in two parts, separated
26912657by a C<\0> byte, the first part describes the input layers, the second
26922658part describes the output layers.
26932659
26942660=end original
26952661
26962662PerlIO で使われる内部変数です。
26972663文字列は C<\0> で分割された二つの部分からなり、前半は入力層を、
26982664後半は出力層を示します。
26992665
27002666=item $PERLDB
27012667
27022668=item $^P
27032669X<$^P> X<$PERLDB>
27042670
27052671=begin original
27062672
27072673The internal variable for debugging support. The meanings of the
27082674various bits are subject to change, but currently indicate:
27092675
27102676=end original
27112677
27122678デバッグ機能のための内部変数です。
27132679それぞれのビットの意味は変わるかもしれませんが、
27142680現在のところは以下の通りです:
27152681
27162682=over 6
27172683
27182684=item 0x01
27192685
27202686=begin original
27212687
27222688Debug subroutine enter/exit.
27232689
27242690=end original
27252691
27262692サブルーチンの出入りをデバッグします。
27272693
27282694=item 0x02
27292695
27302696=begin original
27312697
2732Line-by-line debugging. Causes DB::DB() subroutine to be called for each
2698Line-by-line debugging.
2733statement executed. Also causes saving source code lines (like 0x400).
27342699
27352700=end original
27362701
27372702行毎にデバッグします。
2738各行を実行する毎に DB::DB() サブルーチンを呼び出します。
2739さらに、(0x400 のように) ソースコードを保存します。
27402703
27412704=item 0x04
27422705
27432706=begin original
27442707
27452708Switch off optimizations.
27462709
27472710=end original
27482711
27492712最適化を行いません。
27502713
27512714=item 0x08
27522715
27532716=begin original
27542717
27552718Preserve more data for future interactive inspections.
27562719
27572720=end original
27582721
27592722将来の対話的な検査のためにより多くのデータを保存します。
27602723
27612724=item 0x10
27622725
27632726=begin original
27642727
27652728Keep info about source lines on which a subroutine is defined.
27662729
27672730=end original
27682731
27692732サブルーチンが定義されたソース行に関する情報を保持します。
27702733
27712734=item 0x20
27722735
27732736=begin original
27742737
27752738Start with single-step on.
27762739
27772740=end original
27782741
27792742シングルステップ実行で開始します。
27802743
27812744=item 0x40
27822745
27832746=begin original
27842747
27852748Use subroutine address instead of name when reporting.
27862749
27872750=end original
27882751
27892752報告時にサブルーチン名でなくサブルーチンのアドレスを使います。
27902753
27912754=item 0x80
27922755
27932756=begin original
27942757
27952758Report C<goto &subroutine> as well.
27962759
27972760=end original
27982761
27992762C<goto &subroutine> も同様に報告します。
28002763
28012764=item 0x100
28022765
28032766=begin original
28042767
28052768Provide informative "file" names for evals based on the place they were compiled.
28062769
28072770=end original
28082771
28092772eval に対して、コンパイルされた位置を元にした「ファイル」名を提供します。
28102773
28112774=item 0x200
28122775
28132776=begin original
28142777
28152778Provide informative names to anonymous subroutines based on the place they
28162779were compiled.
28172780
28182781=end original
28192782
28202783無名サブルーチンに対して、
28212784コンパイルされた位置を基にした参考名を提供します。
28222785
28232786=item 0x400
28242787
28252788=begin original
28262789
2827Save source code lines into C<@{"_<$filename"}>.
2790Debug assertion subroutines enter/exit.
28282791
28292792=end original
28302793
2831スコード行数 C<@{"_<$filename"}> に保存します。
2794サブルチン進入/脱出アサートします。
28322795
28332796=back
28342797
28352798=begin original
28362799
28372800Some bits may be relevant at compile-time only, some at
28382801run-time only. This is a new mechanism and the details may change.
2839See also L<perldebguts>.
28402802
28412803=end original
28422804
28432805無名サブルーチンに対して、
28442806コンパイルされた位置を基にした参考名を提供します。
2845See also L<perldebguts>.
28462807
28472808=item $LAST_REGEXP_CODE_RESULT
28482809
28492810=item $^R
28502811X<$^R> X<$LAST_REGEXP_CODE_RESULT>
28512812
28522813=begin original
28532814
28542815The result of evaluation of the last successful C<(?{ code })>
28552816regular expression assertion (see L<perlre>). May be written to.
28562817
28572818=end original
28582819
28592820最後に成功した C<(?{ code })> 正規表現アサートの評価の結果です
28602821(L<perlre> を参照して下さい)。おそらくもっと書き足します。
28612822
28622823=item $EXCEPTIONS_BEING_CAUGHT
28632824
28642825=item $^S
28652826X<$^S> X<$EXCEPTIONS_BEING_CAUGHT>
28662827
28672828=begin original
28682829
28692830Current state of the interpreter.
28702831
28712832=end original
28722833
28732834現在のインタプリタの状態を示します。
28742835
28752836=begin original
28762837
28772838 $^S State
28782839 --------- -------------------
28792840 undef Parsing module/eval
28802841 true (1) Executing an eval
28812842 false (0) Otherwise
28822843
28832844=end original
28842845
2885 $^S 状態
2846 $^S State
28862847 --------- -------------------
28872848 undef モジュール/eval のパース中
28882849 真 (1) eval の実行中
28892850 偽 (0) その他
28902851
28912852=begin original
28922853
28932854The first state may happen in $SIG{__DIE__} and $SIG{__WARN__} handlers.
28942855
28952856=end original
28962857
28972858最初の状態は $SIG{__DIE__} と $SIG{__WARN__} のハンドラで起きる可能性が
28982859あります。
28992860
29002861=item $BASETIME
29012862
29022863=item $^T
29032864X<$^T> X<$BASETIME>
29042865
29052866=begin original
29062867
29072868The time at which the program began running, in seconds since the
29082869epoch (beginning of 1970). The values returned by the B<-M>, B<-A>,
29092870and B<-C> filetests are based on this value.
29102871
29112872=end original
29122873
29132874プログラムを実行開始した時刻を、紀元 (1970年の始め) からの秒数で示したものです。
29142875ファイルテスト B<-M>、B<-A>、B<-C> で返される値は、この値に基づいています。
29152876
29162877=item ${^TAINT}
29172878
29182879=begin original
29192880
29202881Reflects if taint mode is on or off. 1 for on (the program was run with
29212882B<-T>), 0 for off, -1 when only taint warnings are enabled (i.e. with
29222883B<-t> or B<-TU>). This variable is read-only.
29232884
29242885=end original
29252886
29262887汚染検査モードのオン・オフを反映します。
292728881 はオン(プログラムは B<-T> 付きで実行されている)、0 はオフ、-1 は汚染
29282889警告のみが有効になっている(つまり B<-t> か B<-TU>)ことを意味します。
29292890この変数は読み込み専用です。
29302891
29312892=item ${^UNICODE}
29322893
29332894=begin original
29342895
29352896Reflects certain Unicode settings of Perl. See L<perlrun>
29362897documentation for the C<-C> switch for more information about
29372898the possible values. This variable is set during Perl startup
29382899and is thereafter read-only.
29392900
29402901=end original
29412902
29422903Perl のいくつかの Unicode 設定を反映します。
29432904設定できる値に関するさらなる情報については L<perlrun> の C<-C> オプションを
29442905参照してください。
29452906この変数は Perl 起動時に設定され、その後は読み込み専用です。
29462907
29472908=item ${^UTF8CACHE}
29482909
29492910=begin original
29502911
29512912This variable controls the state of the internal UTF-8 offset caching code.
295229131 for on (the default), 0 for off, -1 to debug the caching code by checking
29532914all its results against linear scans, and panicking on any discrepancy.
29542915
29552916=end original
29562917
29572918この変数は内部 UTF-8 オフセットキャッシュコードの状態を制御します。
295829191 はオン(デフォルト)、0 はオフ、-1 は全ての結果を線形走査と比較して、
29592920矛盾があれば異常終了する、という形でキャッシュコードをデバッグします。
29602921
29612922=item ${^UTF8LOCALE}
29622923
29632924=begin original
29642925
2965This variable indicates whether a UTF-8 locale was detected by perl at
2926This variable indicates whether an UTF-8 locale was detected by perl at
29662927startup. This information is used by perl when it's in
29672928adjust-utf8ness-to-locale mode (as when run with the C<-CL> command-line
29682929switch); see L<perlrun> for more info on this.
29692930
29702931=end original
29712932
29722933この変数は、起動時に perl によって UTF-8 ロケールが検出されたかどうかを
29732934示します。
29742935この情報は(C<-CL> コマンドラインスイッチで起動されることによって)
29752936「utf8 性をロケールに合わせる」モードのときに perl によって使われます;
29762937これに関するさらなる情報は L<perlrun> を参照してください。
29772938
29782939=item $PERL_VERSION
29792940
29802941=item $^V
29812942X<$^V> X<$PERL_VERSION>
29822943
29832944=begin original
29842945
29852946The revision, version, and subversion of the Perl interpreter, represented
29862947as a C<version> object.
29872948
29882949=end original
29892950
29902951C<version> オブジェクトとして表現される revision, version, subversion。
29912952
29922953=begin original
29932954
29942955This variable first appeared in perl 5.6.0; earlier versions of perl will
29952956see an undefined value. Before perl 5.10.0 $^V was represented as a v-string.
29962957
29972958=end original
29982959
29992960この変数は perl 5.6.0 で最初に現れました; それより前のバージョンでは
30002961未定義値となります。
30012962perl 5.10.0 以前では $^V は v-string 形式で表現されます。
30022963
30032964=begin original
30042965
30052966$^V can be used to determine whether the Perl interpreter executing a
30062967script is in the right range of versions. (Mnemonic: use ^V for Version
30072968Control.) Example:
30082969
30092970=end original
30102971
30112972$^V はスクリプトを実行している Perl インタプリタのバージョンが
30122973正しい範囲に入っているかを調べるのに使えます。(記憶法:
30132974^V をバージョンコントロールに使います。) 例:
30142975
30152976 warn "Hashes not randomized!\n" if !$^V or $^V lt v5.8.1
30162977
30172978=begin original
30182979
30192980To convert C<$^V> into its string representation use sprintf()'s
30202981C<"%vd"> conversion:
30212982
30222983=end original
30232984
30242985C<$^V> を文字列表現に変換するには sprintf() の C<"%vd"> 変換を使います:
30252986
30262987 printf "version is v%vd\n", $^V; # Perl's version
30272988
30282989=begin original
30292990
30302991See the documentation of C<use VERSION> and C<require VERSION>
30312992for a convenient way to fail if the running Perl interpreter is too old.
30322993
30332994=end original
30342995
30352996実行する Perl インタプリタが古すぎる場合に終了する便利な方法に
30362997ついては C<use VERSION> と C<require VERSION> のドキュメントを
30372998参照して下さい。
30382999
30393000=begin original
30403001
30413002See also C<$]> for an older representation of the Perl version.
30423003
30433004=end original
30443005
30453006Perl バージョンの古い表現については C<$]> も参照して下さい。
30463007
30473008=item $WARNING
30483009
30493010=item $^W
30503011X<$^W> X<$WARNING>
30513012
30523013=begin original
30533014
30543015The current value of the warning switch, initially true if B<-w>
30553016was used, false otherwise, but directly modifiable. (Mnemonic:
30563017related to the B<-w> switch.) See also L<warnings>.
30573018
30583019=end original
30593020
30603021警告スイッチの値で、B<-w> スイッチが使われると内部的に真となり、
30613022そうでない場合は直接変更可能です。
30623023(記憶法: B<-w> スイッチに関係します。)
30633024L<warnings> も参照して下さい。
30643025
30653026=item ${^WARNING_BITS}
30663027
30673028=begin original
30683029
30693030The current set of warning checks enabled by the C<use warnings> pragma.
30703031See the documentation of C<warnings> for more details.
30713032
30723033=end original
30733034
30743035C<use warnings> プラグマで有効にされた、現在の警告チェックの集合です。
30753036詳細については C<warnings> のドキュメントを参照して下さい。
30763037
30773038=item ${^WIN32_SLOPPY_STAT}
3078X<sitecustomize> X<sitecustomize.pl>
30793039
30803040=begin original
30813041
30823042If this variable is set to a true value, then stat() on Windows will
30833043not try to open the file. This means that the link count cannot be
30843044determined and file attributes may be out of date if additional
30853045hardlinks to the file exist. On the other hand, not opening the file
30863046is considerably faster, especially for files on network drives.
30873047
30883048=end original
30893049
30903050この変数が真の値にセットされると、Windows での stat() はファイルを
30913051オープンしようとはしません。
30923052これは、このファイルへの追加のハードリンクが存在する場合、リンクカウントを
30933053決定できませんし、ファイル属性が古いものになるかもしれないことを
30943054意味します。
30953055一方、ファイルを開かないので、(特にファイルがネットワークドライブにある
30963056場合は)大幅に高速です。
30973057
30983058=begin original
30993059
31003060This variable could be set in the F<sitecustomize.pl> file to
31013061configure the local Perl installation to use "sloppy" stat() by
3102default. See the documentation for B<-f> in
3062default. See L<perlrun> for more information about site
3103L<perlrun|perlrun/"Command Switches"> for more information about site
31043063customization.
31053064
31063065=end original
31073066
31083067デフォルトで「ずさんな」stat() を使うために、この変数は、ローカルな
31093068Perl を設定するための F<sitecustomize.pl> で設定できます。
3110サイトカスタマイズに関するさらなる情報については
3069サイトカスタマイズに関するさらなる情報については L<perlrun> を
3111L<perlrun|perlrun/"Command Switches"> の B<-f> を参照してください。
3070参照してください。
31123071
31133072=item $EXECUTABLE_NAME
31143073
31153074=item $^X
31163075X<$^X> X<$EXECUTABLE_NAME>
31173076
31183077=begin original
31193078
31203079The name used to execute the current copy of Perl, from C's
31213080C<argv[0]> or (where supported) F</proc/self/exe>.
31223081
31233082=end original
31243083
31253084Perl バイナリ自身が実行された時の名前を C の argv[0] または (対応していれば)
31263085F</proc/self/exe> から持ってきたものです。
31273086
31283087=begin original
31293088
31303089Depending on the host operating system, the value of $^X may be
31313090a relative or absolute pathname of the perl program file, or may
31323091be the string used to invoke perl but not the pathname of the
31333092perl program file. Also, most operating systems permit invoking
31343093programs that are not in the PATH environment variable, so there
31353094is no guarantee that the value of $^X is in PATH. For VMS, the
31363095value may or may not include a version number.
31373096
31383097=end original
31393098
31403099ホスト OS に依存して、$^X の値は perl プログラムファイルの絶対パスかも
31413100しれませんし、相対パスかもしれませんし、perl を起動するために使われる
31423101文字列ではありますが perl プログラムファイルのパス名ではないかもしれません。
31433102また、ほとんどの OS は PATH 環境変数にない位置のプログラムを起動することを
31443103許しているので、$^X の値が PATH にある保証はありません。
31453104VMS では、この値はバージョン番号を含む場合も含まない場合もあります。
31463105
31473106=begin original
31483107
31493108You usually can use the value of $^X to re-invoke an independent
31503109copy of the same perl that is currently running, e.g.,
31513110
31523111=end original
31533112
31543113通常は、現在実行中のものと同じ perl の独立したコピーを再起動するために
31553114$^X の値を使えます; つまり:
31563115
31573116 @first_run = `$^X -le "print int rand 100 for 1..100"`;
31583117
31593118=begin original
31603119
31613120But recall that not all operating systems support forking or
31623121capturing of the output of commands, so this complex statement
31633122may not be portable.
31643123
31653124=end original
31663125
31673126しかし、全ての OS が fork やコマンドの出力の捕捉に対応しているわけでは
31683127ないので、この複雑な文は移植性がないかもしれないことを忘れないでください。
31693128
31703129=begin original
31713130
31723131It is not safe to use the value of $^X as a path name of a file,
31733132as some operating systems that have a mandatory suffix on
31743133executable files do not require use of the suffix when invoking
31753134a command. To convert the value of $^X to a path name, use the
31763135following statements:
31773136
31783137=end original
31793138
31803139$^X の値をファイルのパス名として使うのは安全ではありません;
31813140実行ファイルに固定の接尾辞があり、コマンドの起動時には接尾辞が不要な OS も
31823141あるからです。
31833142$^X の値をパス名に変換するには、以下のコードを使ってください:
31843143
31853144 # Build up a set of file names (not command names).
31863145 use Config;
31873146 $this_perl = $^X;
31883147 if ($^O ne 'VMS')
31893148 {$this_perl .= $Config{_exe}
31903149 unless $this_perl =~ m/$Config{_exe}$/i;}
31913150
31923151=begin original
31933152
31943153Because many operating systems permit anyone with read access to
31953154the Perl program file to make a copy of it, patch the copy, and
31963155then execute the copy, the security-conscious Perl programmer
31973156should take care to invoke the installed copy of perl, not the
31983157copy referenced by $^X. The following statements accomplish
31993158this goal, and produce a pathname that can be invoked as a
32003159command or referenced as a file.
32013160
32023161=end original
32033162
32043163多くの OS が Perl のプログラムファイルのコピーを作って、コピーに
32053164パッチを当て、それを実行するための読み込み権限を全員に与えているので、
32063165セキュリティ意識のある Perl プログラマは $^X で参照されているコピーではなく、
32073166インストールされている perl を起動するように気をつけるべきです。
32083167以下のコードはこの目的を達成し、コマンドとして起動したりファイルとして
32093168参照するためのパス名を作成します。
32103169
32113170 use Config;
32123171 $secure_perl_path = $Config{perlpath};
32133172 if ($^O ne 'VMS')
32143173 {$secure_perl_path .= $Config{_exe}
32153174 unless $secure_perl_path =~ m/$Config{_exe}$/i;}
32163175
32173176=item ARGV
32183177X<ARGV>
32193178
32203179=begin original
32213180
32223181The special filehandle that iterates over command-line filenames in
32233182C<@ARGV>. Usually written as the null filehandle in the angle operator
32243183C<< <> >>. Note that currently C<ARGV> only has its magical effect
32253184within the C<< <> >> operator; elsewhere it is just a plain filehandle
32263185corresponding to the last file opened by C<< <> >>. In particular,
32273186passing C<\*ARGV> as a parameter to a function that expects a filehandle
32283187may not cause your function to automatically read the contents of all the
32293188files in C<@ARGV>.
32303189
32313190=end original
32323191
32333192C<@ARGV> にあるコマンドラインで指定されたファイル名に対して反復する
32343193特殊ファイルハンドルです。
32353194通常角かっこ C<< <> >> の中で空ファイルハンドルとして書かれます。
32363195現在のところ、C<ARGV> は C<< <> >> 演算子の中でのみ特別な効果があることに
32373196注意してください; その他の場所では、C<< <> >> で開かれた最後のファイルに
32383197対応する普通のファイルハンドルです。
32393198特に、ファイルハンドルを想定している関数に C<\*ARGV> を引数として渡しても、
32403199関数内で C<@ARGV> にある全てのファイルの内容を自動的に読み込むことには
32413200なりません。
32423201
32433202=item $ARGV
32443203X<$ARGV>
32453204
32463205=begin original
32473206
32483207contains the name of the current file when reading from <>.
32493208
32503209=end original
32513210
32523211<> から読込みを行なっているとき、その時点のファイル名を示します。
32533212
32543213=item @ARGV
32553214X<@ARGV>
32563215
32573216=begin original
32583217
32593218The array @ARGV contains the command-line arguments intended for
32603219the script. C<$#ARGV> is generally the number of arguments minus
32613220one, because C<$ARGV[0]> is the first argument, I<not> the program's
32623221command name itself. See C<$0> for the command name.
32633222
32643223=end original
32653224
32663225配列 @ARGV は、コマンドラインからスクリプトに渡す引数が入れられます。
32673226C<$ARGV[0]> がI<プログラムのコマンド名自身ではなく>、
32683227最初の引数ですから、C<$#ARGV> は一般には、引数の個数 - 1 となります。
32693228コマンド名については、C<$0> を参照してください。
32703229
32713230=item ARGVOUT
32723231X<ARGVOUT>
32733232
32743233=begin original
32753234
32763235The special filehandle that points to the currently open output file
32773236when doing edit-in-place processing with B<-i>. Useful when you have
32783237to do a lot of inserting and don't want to keep modifying $_. See
32793238L<perlrun> for the B<-i> switch.
32803239
32813240=end original
32823241
32833242B<-i> を使ってその場修正を行っているときに、現在開いている出力ファイルを
32843243示す特殊ファイルハンドルです。
32853244たくさんの挿入をする必要があるときに $_ を修正し続けたくない場合に
32863245有用です。
32873246B<-i> オプションについては L<perlrun> を参照してください。
32883247
32893248=item @F
32903249X<@F>
32913250
32923251=begin original
32933252
32943253The array @F contains the fields of each line read in when autosplit
32953254mode is turned on. See L<perlrun> for the B<-a> switch. This array
32963255is package-specific, and must be declared or given a full package name
32973256if not in package main when running under C<strict 'vars'>.
32983257
32993258=end original
33003259
33013260自動 split モードが有効の場合、配列 @F には読み込んだ行のフィールドを
33023261含みます。
33033262B<-a> オプションについては L<perlrun> を参照してください。
33043263この配列はパッケージ固有であり、もし C<strict 'vars'> で実行していて
33053264パッケージ main 以外の場合は完全なパッケージ名で定義したり与えたり
33063265しなければなりません。
33073266
33083267=item @INC
33093268X<@INC>
33103269
33113270=begin original
33123271
33133272The array @INC contains the list of places that the C<do EXPR>,
33143273C<require>, or C<use> constructs look for their library files. It
33153274initially consists of the arguments to any B<-I> command-line
33163275switches, followed by the default Perl library, probably
33173276F</usr/local/lib/perl>, followed by ".", to represent the current
33183277directory. ("." will not be appended if taint checks are enabled, either by
33193278C<-T> or by C<-t>.) If you need to modify this at runtime, you should use
33203279the C<use lib> pragma to get the machine-dependent library properly
33213280loaded also:
33223281
33233282=end original
33243283
33253284配列 @INC には、do EXPR、require、use によってライブラリファイルを
33263285探すときに評価する場所のリストが納められています。
33273286初期状態では、コマンドラインスイッチ B<-I> の引数と
33283287デフォルトの Perl ライブラリディレクトリ (おそらく
33293288F</usr/local/lib/perl5>) とカレントディレクトリを表わす
33303289"." を順につなげたものです。
33313290(C<-T> か C<-t> によって汚染チェックが有効の場合は、"." は追加されません。)
33323291実行時にこれを変更する必要がある場合は、マシン依存のライブラリも正しく
33333292読み込むために C<use lib> を使うべきです:
33343293
33353294 use lib '/mypath/libdir/';
33363295 use SomeMod;
33373296
33383297=begin original
33393298
33403299You can also insert hooks into the file inclusion system by putting Perl
33413300code directly into @INC. Those hooks may be subroutine references, array
33423301references or blessed objects. See L<perlfunc/require> for details.
33433302
33443303=end original
33453304
33463305Perl のコードを直接 @INC に入れることで、ファイルインクルード機構に
33473306フックを挿入できます。
33483307このフックはサブルーチンリファレンス、配列リファレンス、bless された
33493308オブジェクトが可能です。
33503309詳細については L<perlfunc/require> を参照してください。
33513310
33523311=item @ARG
33533312
33543313=item @_
33553314X<@_> X<@ARG>
33563315
33573316=begin original
33583317
33593318Within a subroutine the array @_ contains the parameters passed to that
33603319subroutine. See L<perlsub>.
33613320
33623321=end original
33633322
33643323サブルーチンの内部では、配列 @_ はサブルーチンに渡されたパラメータです。
33653324L<perlsub> を参照して下さい。
33663325
33673326=item %INC
33683327X<%INC>
33693328
33703329=begin original
33713330
33723331The hash %INC contains entries for each filename included via the
33733332C<do>, C<require>, or C<use> operators. The key is the filename
33743333you specified (with module names converted to pathnames), and the
33753334value is the location of the file found. The C<require>
33763335operator uses this hash to determine whether a particular file has
33773336already been included.
33783337
33793338=end original
33803339
33813340ハッシュ %INC は、C<do>, C<require>, C<use>演算子によって
33823341インクルードされた、個々のファイル名をエントリとして持っています。
33833342key は指定したファイル名(モジュール名はパス名に変換されます)で、
33843343value は見つかった場所となっています。
33853344C<require> 演算子は、指定されたファイル名が既に
33863345インクルードされているかを、このハッシュを使って調べます。
33873346
33883347=begin original
33893348
33903349If the file was loaded via a hook (e.g. a subroutine reference, see
33913350L<perlfunc/require> for a description of these hooks), this hook is
33923351by default inserted into %INC in place of a filename. Note, however,
33933352that the hook may have set the %INC entry by itself to provide some more
33943353specific info.
33953354
33963355=end original
33973356
33983357ファイルがフック(つまりサブルーチンリファレンス; フックに関する
33993358説明については L<perlfunc/require> を参照してください)経由で読み込まれた
34003359場合、このフックはデフォルトではファイル名の代わりに %INC に挿入されます。
34013360しかし、フックはさらなる特定の情報を提供するために、自身で %INC エントリを
34023361セットするかもしれないことに注意してください。
34033362
34043363=item %ENV
34053364
34063365=item $ENV{expr}
34073366X<%ENV>
34083367
34093368=begin original
34103369
34113370The hash %ENV contains your current environment. Setting a
34123371value in C<ENV> changes the environment for any child processes
34133372you subsequently fork() off.
34143373
34153374=end original
34163375
34173376ハッシュ %ENV には、その時点の環境変数が設定されています。
34183377C<ENV> に値を設定することで、
34193378以後に fork() した子プロセスの環境変数を変更します。
34203379
34213380=item %SIG
34223381
34233382=item $SIG{expr}
34243383X<%SIG>
34253384
34263385=begin original
34273386
34283387The hash C<%SIG> contains signal handlers for signals. For example:
34293388
34303389=end original
34313390
34323391ハッシュ C<%SIG> にはシグナルのためのシグナルハンドラが含まれています。
34333392例えば:
34343393
34353394 sub handler { # 1st argument is signal name
34363395 my($sig) = @_;
34373396 print "Caught a SIG$sig--shutting down\n";
34383397 close(LOG);
34393398 exit(0);
34403399 }
34413400
34423401 $SIG{'INT'} = \&handler;
34433402 $SIG{'QUIT'} = \&handler;
34443403 ...
34453404 $SIG{'INT'} = 'DEFAULT'; # restore default action
34463405 $SIG{'QUIT'} = 'IGNORE'; # ignore SIGQUIT
34473406
34483407=begin original
34493408
34503409Using a value of C<'IGNORE'> usually has the effect of ignoring the
34513410signal, except for the C<CHLD> signal. See L<perlipc> for more about
34523411this special case.
34533412
34543413=end original
34553414
34563415C<'IGNORE'> という値は通常はシグナルの効果を無視するために使いますが、
34573416C<CHLD> シグナルは例外です。
34583417この特別な場合に関する詳細は L<perlipc> を参照して下さい。
34593418
34603419=begin original
34613420
34623421Here are some other examples:
34633422
34643423=end original
34653424
34663425以下にその他の例を示します:
34673426
34683427=begin original
34693428
34703429 $SIG{"PIPE"} = "Plumber"; # assumes main::Plumber (not recommended)
34713430 $SIG{"PIPE"} = \&Plumber; # just fine; assume current Plumber
34723431 $SIG{"PIPE"} = *Plumber; # somewhat esoteric
34733432 $SIG{"PIPE"} = Plumber(); # oops, what did Plumber() return??
34743433
34753434=end original
34763435
34773436 $SIG{"PIPE"} = "Plumber"; # main::Plumber を仮定します(非推奨)
34783437 $SIG{"PIPE"} = \&Plumber; # 問題なし; カレントの Plumber を仮定します
34793438 $SIG{"PIPE"} = *Plumber; # 少々難解
34803439 $SIG{"PIPE"} = Plumber(); # げげ、Plumber() は何を返すの??
34813440
34823441=begin original
34833442
34843443Be sure not to use a bareword as the name of a signal handler,
34853444lest you inadvertently call it.
34863445
34873446=end original
34883447
34893448裸の単語をシグナルハンドラの名前として使わないようにしてください。
34903449不注意で呼び出すのを避けるためです。
34913450
34923451=begin original
34933452
34943453If your system has the sigaction() function then signal handlers are
34953454installed using it. This means you get reliable signal handling.
34963455
34973456=end original
34983457
34993458システムに sigaction() 関数がある場合は、
35003459シグナルハンドラはこの関数を使って設定されます。
35013460これにより、信頼性のあるシグナルハンドリングが可能になります。
35023461
35033462=begin original
35043463
35053464The default delivery policy of signals changed in Perl 5.8.0 from
35063465immediate (also known as "unsafe") to deferred, also known as
35073466"safe signals". See L<perlipc> for more information.
35083467
35093468=end original
35103469
35113470デフォルトのシグナル配送ポリシーは Perl 5.8.0 に即時("unsafe"としても
35123471知られます)から保留(「安全なシグナル」としても知られます)に変更されました。
35133472さらなる情報については L<perlipc> を参照してください。
35143473
35153474=begin original
35163475
35173476Certain internal hooks can be also set using the %SIG hash. The
35183477routine indicated by C<$SIG{__WARN__}> is called when a warning message is
35193478about to be printed. The warning message is passed as the first
35203479argument. The presence of a C<__WARN__> hook causes the ordinary printing
35213480of warnings to C<STDERR> to be suppressed. You can use this to save warnings
35223481in a variable, or turn warnings into fatal errors, like this:
35233482
35243483=end original
35253484
35263485ある種の内部フックも %SIG ハッシュを使ってセットされます。
35273486警告メッセージを表示しようとするときに C<$SIG{__WARN__}> で
35283487示されたルーチンが呼び出されます。
35293488警告メッセージは最初の引数として渡されます。
35303489C<__WARN__> フックがあると、通常の C<STDERR> への警告の出力は行われません。
35313490これを使って、警告メッセージを変数にいれたり、
35323491あるいは以下のようにして警告を致命的エラーに変えたり出来ます:
35333492
35343493 local $SIG{__WARN__} = sub { die $_[0] };
35353494 eval $proggie;
35363495
35373496=begin original
35383497
35393498As the C<'IGNORE'> hook is not supported by C<__WARN__>, you can
35403499disable warnings using the empty subroutine:
35413500
35423501=end original
35433502
35443503C<__WARN__> では C<'IGNORE'> フックには対応していないので、空サブルーチンを
35453504使って警告を無効に出来ます:
35463505
35473506 local $SIG{__WARN__} = sub {};
35483507
35493508=begin original
35503509
35513510The routine indicated by C<$SIG{__DIE__}> is called when a fatal exception
35523511is about to be thrown. The error message is passed as the first
35533512argument. When a C<__DIE__> hook routine returns, the exception
35543513processing continues as it would have in the absence of the hook,
35553514unless the hook routine itself exits via a C<goto>, a loop exit, or a C<die()>.
35563515The C<__DIE__> handler is explicitly disabled during the call, so that you
35573516can die from a C<__DIE__> handler. Similarly for C<__WARN__>.
35583517
35593518=end original
35603519
35613520C<$SIG{__DIE__}> で示されるルーチンは
35623521致命的な例外がまさに投げられようとするときに呼び出されます。
35633522エラーメッセージは最初の引数として渡されます。
35643523C<__DIE__> フックから戻ると、
35653524例外処理はフックがなかったかのように再開されますが、
35663525フックルーチン自体が C<goto>、ループ終了、C<die()> によって
35673526終了した場合を除きます。
35683527C<__DIE__> ハンドラは呼び出し中は明示的に無効になりますので、
35693528C<__DIE__> ハンドラから die できます。
35703529C<__WARN__> も同様です。
35713530
35723531=begin original
35733532
35743533Due to an implementation glitch, the C<$SIG{__DIE__}> hook is called
35753534even inside an eval(). Do not use this to rewrite a pending exception
35763535in C<$@>, or as a bizarre substitute for overriding C<CORE::GLOBAL::die()>.
35773536This strange action at a distance may be fixed in a future release
35783537so that C<$SIG{__DIE__}> is only called if your program is about
35793538to exit, as was the original intent. Any other use is deprecated.
35803539
35813540=end original
35823541
35833542実装上の不具合により、C<$SIG{__DIE__}> は eval() の中でも
35843543呼び出されます。これを、C<$@> の待っている例外を書き換えたり、
35853544C<CORE::GLOBAL::die()> を上書きするのに使わないでください。
35863545この奇妙な行動は将来のリリースで修正される予定なので、
35873546C<$SIG{__DIE__}> は当初の目的通り、
35883547プログラムが終了するときにのみ呼び出されるようになります。
35893548その他の用途は非推奨です。
35903549
35913550=begin original
35923551
35933552C<__DIE__>/C<__WARN__> handlers are very special in one respect:
35943553they may be called to report (probable) errors found by the parser.
35953554In such a case the parser may be in inconsistent state, so any
35963555attempt to evaluate Perl code from such a handler will probably
35973556result in a segfault. This means that warnings or errors that
35983557result from parsing Perl should be used with extreme caution, like
35993558this:
36003559
36013560=end original
36023561
36033562C<__DIE__> と C<__WARN__> のハンドラは一つの点で非常に特別です。
36043563パーザによってエラー(であろうもの)を報告するために呼び出されることがある
36053564ことです。
36063565このような場合、パーザは不安定な状態になっているかもしれないので、
36073566ハンドラから Perl コードを評価しようとするとセグメンテーションフォールトが
36083567発生するかもしれません。
36093568Perl のパーズ中の警告やエラーは、以下のように非常に注意して扱うべきです。
36103569
36113570 require Carp if defined $^S;
36123571 Carp::confess("Something wrong") if defined &Carp::confess;
36133572 die "Something wrong, but could not load Carp to give backtrace...
36143573 To see backtrace try starting Perl with -MCarp switch";
36153574
36163575=begin original
36173576
36183577Here the first line will load Carp I<unless> it is the parser who
36193578called the handler. The second line will print backtrace and die if
36203579Carp was available. The third line will be executed only if Carp was
36213580not available.
36223581
36233582=end original
36243583
36253584一行目は、I<パーザがハンドラを呼び出したのでなければ>
36263585Carp を読み込みます。
36273586二行目は、Carp が使えるならバックとレースを表示して die します。
36283587三行目は Carp が使えないときにのみ実行されます。
36293588
36303589=begin original
36313590
36323591See L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>, and
36333592L<warnings> for additional information.
36343593
36353594=end original
36363595
36373596追加の情報については L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>,
36383597L<warnings> を参照して下さい。
36393598
36403599=back
36413600
36423601=head2 Error Indicators
36433602X<error> X<exception>
36443603
36453604(エラー指示子)
36463605
36473606=begin original
36483607
36493608The variables C<$@>, C<$!>, C<$^E>, and C<$?> contain information
36503609about different types of error conditions that may appear during
36513610execution of a Perl program. The variables are shown ordered by
36523611the "distance" between the subsystem which reported the error and
36533612the Perl process. They correspond to errors detected by the Perl
36543613interpreter, C library, operating system, or an external program,
36553614respectively.
36563615
36573616=end original
36583617
36593618変数 C<$@>, C<$!>, C<$^E>, C<$?> は Perl プログラムの実行中に
36603619発生した、異なる種類のエラー情報を保持します。
36613620変数はエラーを報告した副システムと Perl プロセスとの「距離」
36623621の順番に並んでいます。
36633622これらはそれぞれ、Perl インタプリタ、C ライブラリ、
36643623オペレーティングシステム、外部プログラムによって検出された
36653624エラーに対応しています。
36663625
36673626=begin original
36683627
36693628To illustrate the differences between these variables, consider the
36703629following Perl expression, which uses a single-quoted string:
36713630
36723631=end original
36733632
36743633これらの変数の違いを示すために、
36753634以下のようなシングルクォートを用いた Perl 式を考えます:
36763635
36773636 eval q{
36783637 open my $pipe, "/cdrom/install |" or die $!;
36793638 my @res = <$pipe>;
36803639 close $pipe or die "bad pipe: $?, $!";
36813640 };
36823641
36833642=begin original
36843643
36853644After execution of this statement all 4 variables may have been set.
36863645
36873646=end original
36883647
36893648この文を実行した後、4 つの変数全てがセットされる可能性があります。
36903649
36913650=begin original
36923651
36933652C<$@> is set if the string to be C<eval>-ed did not compile (this
36943653may happen if C<open> or C<close> were imported with bad prototypes),
36953654or if Perl code executed during evaluation die()d . In these cases
36963655the value of $@ is the compile error, or the argument to C<die>
36973656(which will interpolate C<$!> and C<$?>). (See also L<Fatal>,
36983657though.)
36993658
37003659=end original
37013660
37023661C<$@> は C<eval> された文字列がコンパイルされなかったとき
37033662(これは C<open> か C<close> が正しくない
37043663プロトタイプでインポートされたときに起こり得ます)、
37053664または評価中に実行している Perl コードが die() したときにセットされます。
37063665これらの場合には $@ の値はコンパイルエラー、または
37073666C<die> への引数(これには C<$!> と C<$?> が差し挟まれます)です。
37083667(しかし、L<Fatal> も参照して下さい。)
37093668
37103669=begin original
37113670
37123671When the eval() expression above is executed, open(), C<< <PIPE> >>,
37133672and C<close> are translated to calls in the C run-time library and
37143673thence to the operating system kernel. C<$!> is set to the C library's
37153674C<errno> if one of these calls fails.
37163675
37173676=end original
37183677
37193678上記の eval() 式が実行された後、
37203679open(), C<< <PIPE> >>, C<close> は C ランタイムライブラリの呼び出しに
37213680変換され、それからオペレーティングシステムコールに変換されます。
37223681C<$!> はこれらの呼び出しのどれかが失敗したとき、
37233682C ライブラリの C<errno> の値がセットされます。
37243683
37253684=begin original
37263685
37273686Under a few operating systems, C<$^E> may contain a more verbose
37283687error indicator, such as in this case, "CDROM tray not closed."
37293688Systems that do not support extended error messages leave C<$^E>
37303689the same as C<$!>.
37313690
37323691=end original
37333692
37343693いくつかのオペレーティングシステムでは、
37353694C<$^E> により詳細なエラー指示子が入っているかもしれません。
37363695今回の場合で言えば、"CDROM tray not closed." などです。
37373696追加のエラーメッセージに対応していないシステムでは、
37383697C<$^E> は C<$!> と同じ値です。
37393698
37403699=begin original
37413700
37423701Finally, C<$?> may be set to non-0 value if the external program
37433702F</cdrom/install> fails. The upper eight bits reflect specific
37443703error conditions encountered by the program (the program's exit()
37453704value). The lower eight bits reflect mode of failure, like signal
37463705death and core dump information See wait(2) for details. In
37473706contrast to C<$!> and C<$^E>, which are set only if error condition
37483707is detected, the variable C<$?> is set on each C<wait> or pipe
37493708C<close>, overwriting the old value. This is more like C<$@>, which
37503709on every eval() is always set on failure and cleared on success.
37513710
37523711=end original
37533712
37543713最後に、C<$?> は外部プログラム F</cdrom/install> が失敗したときに
37553714非 0 にセットされるかもしれません。
37563715上位の 8 ビットはプログラムが遭遇した特定のエラー状況
37573716(プログラムの exit() の値)を反映します。
37583717下位の 8 ビットは、シグナルの死亡やコアダンプ情報と言った失敗のモードを反映します。
37593718詳細については wait(2) を参照して下さい。
37603719C<$!> と C<$^E> はエラー状況が検出されたときにのみ設定されますが、
37613720変数 C<$?> は C<wait> やパイプの C<close> の度に、前の値を上書きします。
37623721これは、C<$@> が eval() の実行毎に、エラーならセットされ、
37633722成功ならクリアされるという動作と似ています。
37643723
37653724=begin original
37663725
37673726For more details, see the individual descriptions at C<$@>, C<$!>, C<$^E>,
37683727and C<$?>.
37693728
37703729=end original
37713730
37723731より詳細については、C<$@>, C<$!>, C<$^E>, C<$?> それぞれの説明を
37733732参照して下さい。
37743733
37753734=head2 Technical Note on the Syntax of Variable Names
37763735
37773736(変数名の文法に関するテクニカルノート)
37783737
37793738=begin original
37803739
37813740Variable names in Perl can have several formats. Usually, they
37823741must begin with a letter or underscore, in which case they can be
37833742arbitrarily long (up to an internal limit of 251 characters) and
37843743may contain letters, digits, underscores, or the special sequence
37853744C<::> or C<'>. In this case, the part before the last C<::> or
37863745C<'> is taken to be a I<package qualifier>; see L<perlmod>.
37873746
37883747=end original
37893748
37903749Perl の変数名は様々な形があります。
37913750通常、変数名は英文字か下線で始まらなければならず、
37923751任意の長さ(内部制限の 251 文字まで)を取ることができ、
37933752英文字、数字、下線、特別な文字列である C<::> と C<'> を含むことができます。
37943753この場合、最後の C<::> または C<'> の前は
37953754I<パッケージ限定子> として扱われます。
37963755L<perlmod> を参照して下さい。
37973756
37983757=begin original
37993758
38003759Perl variable names may also be a sequence of digits or a single
38013760punctuation or control character. These names are all reserved for
38023761special uses by Perl; for example, the all-digits names are used
38033762to hold data captured by backreferences after a regular expression
38043763match. Perl has a special syntax for the single-control-character
38053764names: It understands C<^X> (caret C<X>) to mean the control-C<X>
38063765character. For example, the notation C<$^W> (dollar-sign caret
38073766C<W>) is the scalar variable whose name is the single character
38083767control-C<W>. This is better than typing a literal control-C<W>
38093768into your program.
38103769
38113770=end original
38123771
38133772Perl の変数は、数字の列または一文字の句読点かコントロール文字の
38143773場合もあります。
38153774これらの名前は全て Perl によって特別な用途のために予約されています。
38163775例えば、全て数字の名前は正規表現マッチの後の後方参照のデータを
38173776保持するために用いられます。
38183777Perl には一文字のコントロール文字の名前のための特別な文法があります。
38193778C<^X>(キャレット C<X>)は control-C<X> キャラクタを意味します。
38203779例えば、C<$^W>(ドル記号 キャレット C<W>)は control-C<W> 一文字の
38213780名前をもつスカラ変数です。
38223781これはプログラム中にリテラルな control-C<W> をタイプするより
38233782良いです。
38243783
38253784=begin original
38263785
38273786Finally, new in Perl 5.6, Perl variable names may be alphanumeric
38283787strings that begin with control characters (or better yet, a caret).
38293788These variables must be written in the form C<${^Foo}>; the braces
38303789are not optional. C<${^Foo}> denotes the scalar variable whose
38313790name is a control-C<F> followed by two C<o>'s. These variables are
38323791reserved for future special uses by Perl, except for the ones that
38333792begin with C<^_> (control-underscore or caret-underscore). No
38343793control-character name that begins with C<^_> will acquire a special
38353794meaning in any future version of Perl; such names may therefore be
38363795used safely in programs. C<$^_> itself, however, I<is> reserved.
38373796
38383797=end original
38393798
38403799最後に、Perl 5.6 の新機能として、コントロール文字(もっと言えばキャレット)で
38413800始まる、英数字からなる文字列の変数名も使えます。
38423801これらの変数は C<${^Foo}> の形で書かれなければなりません。
38433802括弧は必須です。
38443803C<${^Foo}> はコントロール-C<F> の後に二つ C<o> が続く名前を持つ
38453804スカラ変数です。
38463805これらの変数は Perl によって特別な用途のために予約されていますが、
38473806C<^_> (コントロール-下線またはキャレット-下線)で始まるものは例外です。
38483807C<^_> で始まるコントロール文字名は Perl の将来のバージョンで
38493808特別な意味を持つことはありません。
38503809従ってこれらの名前はプログラム中で安全に使用できます。
38513810但し、C<$^_> そのものは I<予約されます>。
38523811
38533812=begin original
38543813
38553814Perl identifiers that begin with digits, control characters, or
38563815punctuation characters are exempt from the effects of the C<package>
38573816declaration and are always forced to be in package C<main>; they are
38583817also exempt from C<strict 'vars'> errors. A few other names are also
38593818exempt in these ways:
38603819
38613820=end original
38623821
38633822数字、コントロール文字、句読点で始まる Perl の識別子は
38643823C<package> 宣言の効果から逃れて、常に C<main> パッケージにあるものとして
38653824扱われます。さらに以下のものも逃れます:
38663825
38673826 ENV STDIN
38683827 INC STDOUT
38693828 ARGV STDERR
38703829 ARGVOUT _
38713830 SIG
38723831
38733832=begin original
38743833
38753834In particular, the new special C<${^_XYZ}> variables are always taken
38763835to be in package C<main>, regardless of any C<package> declarations
38773836presently in scope.
38783837
38793838=end original
38803839
38813840特に、新しい特別な C<${^_XYZ}> 変数はスコープ内の C<package> 宣言に関わらず
38823841常に C<main> パッケージとして扱われます。
38833842
38843843=head1 BUGS
38853844
38863845(バグ)
38873846
38883847=begin original
38893848
38903849Due to an unfortunate accident of Perl's implementation, C<use
38913850English> imposes a considerable performance penalty on all regular
38923851expression matches in a program, regardless of whether they occur
38933852in the scope of C<use English>. For that reason, saying C<use
38943853English> in libraries is strongly discouraged. See the
38953854Devel::SawAmpersand module documentation from CPAN
38963855( http://www.cpan.org/modules/by-module/Devel/ )
38973856for more information. Writing C<use English '-no_match_vars';>
38983857avoids the performance penalty.
38993858
39003859=end original
39013860
39023861Perl の実装における不幸な事故により、
39033862C<use English> はプログラム中の全ての正規表現マッチングにおいて
39043863かなりの性能低下を引き起こします。
39053864これは C<use English> のスコープ内かどうかに関わりません。
39063865この理由により、ライブラリで C<use English> を使うのは
39073866できるだけ避けてください。
39083867さらなる情報については CPAN の Devel::SawAmpersand モジュール
39093868(http://www.perl.com/CPAN/modules/by-module/Devel/) の
39103869ドキュメントを参照して下さい。
39113870
39123871=begin original
39133872
39143873Having to even think about the C<$^S> variable in your exception
39153874handlers is simply wrong. C<$SIG{__DIE__}> as currently implemented
39163875invites grievous and difficult to track down errors. Avoid it
39173876and use an C<END{}> or CORE::GLOBAL::die override instead.
39183877
39193878=end original
39203879
39213880例外ハンドラの中で C<$^S> を使おうなどとは考えてもいけません。
39223881現在の実装の C<$SIG{__DIE__}> は面倒を引き寄せ、エラーの追跡を困難にします。
39233882これの代わりに C<END{}> を使うか、CORE::GLOBAL::die をオーバーライドしてください。
39243883
39253884=begin meta
39263885
39273886Translate: 吉村 寿人 <JAE00534@niftyserve.or.jp> (5.000)
39283887Update: Kentaro Shirakata <argrath@ub32.org> (5.6.1-)
39293888
39303889=end meta