perlvar >
5.10.1
との差分
perlvar 5.10.1 と 5.6.1 の差分
1 | ||
2 | 1 | =encoding euc-jp |
3 | 2 | |
4 | 3 | =head1 NAME |
5 | 4 | |
6 | 5 | =begin original |
7 | 6 | |
8 | 7 | perlvar - Perl predefined variables |
9 | 8 | |
10 | 9 | =end original |
11 | 10 | |
12 | 11 | perlvar - Perl で定義済みの変数 |
13 | 12 | |
14 | 13 | =head1 DESCRIPTION |
15 | 14 | |
16 | 15 | =head2 Predefined Names |
17 | 16 | |
18 | 17 | (定義済みの変数) |
19 | 18 | |
20 | 19 | =begin original |
21 | 20 | |
22 | 21 | The following names have special meaning to Perl. Most |
23 | 22 | punctuation names have reasonable mnemonics, or analogs in the |
24 | 23 | shells. Nevertheless, if you wish to use long variable names, |
25 | 24 | you need only say |
26 | 25 | |
27 | 26 | =end original |
28 | 27 | |
29 | 28 | 以下の名前は Perl では特別な意味を持ちます。 |
30 | 29 | 記号的な名前の多くは記憶法があるか、シェルでの類推が可能です。 |
31 | 30 | それでも長い名前を使用したい場合には |
32 | 31 | |
33 | 32 | use English; |
34 | 33 | |
35 | 34 | =begin original |
36 | 35 | |
37 | at the top of your program. This alias | |
36 | at the top of your program. This will alias all the short names to the | |
38 | names in the current package. Some even have medium names, | |
37 | long names in the current package. Some even have medium names, | |
39 | borrowed from B<awk>. | |
38 | generally borrowed from B<awk>. | |
40 | 39 | |
41 | 40 | =end original |
42 | 41 | |
43 | 42 | とプログラムの最初に書いてください。 |
44 | 43 | これは、すべての短い名前の別名として、 |
45 | 44 | カレントパッケージで長い名前を付けるものです。 |
46 | 45 | B<awk> から持ってきた中間的な名前を持っているものもあります。 |
47 | 一般的に、一番良い使い方は: | |
48 | 46 | |
49 | use English '-no_match_vars'; | |
50 | ||
51 | 47 | =begin original |
52 | 48 | |
53 | ||
49 | If you don't mind the performance hit, variables that depend on the | |
54 | ||
50 | currently selected filehandle may instead be set by calling an | |
55 | ||
51 | appropriate object method on the IO::Handle object. (Summary lines | |
52 | below for this contain the word HANDLE.) First you must say | |
56 | 53 | |
57 | 54 | =end original |
58 | 55 | |
59 | ||
56 | 性能を気にしないのなら、現在選択されているファイルハンドルに | |
60 | 正規表現を使うときのパフォーマンスへの打撃を避けられます。 | |
61 | L<English> を参照してください。 | |
62 | ||
63 | =begin original | |
64 | ||
65 | Variables that depend on the currently selected filehandle may be set by | |
66 | calling an appropriate object method on the IO::Handle object, although | |
67 | this is less efficient than using the regular built-in variables. (Summary | |
68 | lines below for this contain the word HANDLE.) First you must say | |
69 | ||
70 | =end original | |
71 | ||
72 | 現在選択されているファイルハンドルに | |
73 | 57 | 依存する変数の場合には、代わりに IO::Handle オブジェクトに |
74 | 関するオブジェクトメソッドを呼び出して設定することができます | |
58 | 関するオブジェクトメソッドを呼び出して設定することができます。 | |
75 | 通常の組み込み変数よりは効率が落ちます。 | |
76 | 59 | (以下の要約では HANDLE という語を含んでいます。) |
77 | 60 | まず最初に必ず、 |
78 | 61 | |
79 | 62 | use IO::Handle; |
80 | 63 | |
81 | 64 | =begin original |
82 | 65 | |
83 | 66 | after which you may use either |
84 | 67 | |
85 | 68 | =end original |
86 | 69 | |
87 | 70 | と書き、その後で以下のように書くか、 |
88 | 71 | |
89 | 72 | method HANDLE EXPR |
90 | 73 | |
91 | 74 | =begin original |
92 | 75 | |
93 | 76 | or more safely, |
94 | 77 | |
95 | 78 | =end original |
96 | 79 | |
97 | 80 | もしくはより安全に以下のように書きます: |
98 | 81 | |
99 | 82 | HANDLE->method(EXPR) |
100 | 83 | |
101 | 84 | =begin original |
102 | 85 | |
103 | 86 | Each method returns the old value of the IO::Handle attribute. |
104 | The methods each take an optional EXPR, which | |
87 | The methods each take an optional EXPR, which if supplied specifies the | |
105 | 88 | new value for the IO::Handle attribute in question. If not supplied, |
106 | 89 | most methods do nothing to the current value--except for |
107 | 90 | autoflush(), which will assume a 1 for you, just to be different. |
91 | Because loading in the IO::Handle class is an expensive operation, you should | |
92 | learn how to use the regular built-in variables. | |
108 | 93 | |
109 | 94 | =end original |
110 | 95 | |
111 | 96 | それぞれのメソッドは、IO::Handle 属性の昔の値を返します。 |
112 | 97 | メソッドはそれぞれ EXPR をとることができ、指定した場合には、 |
113 | 98 | 問題の IO::Handle 属性の新しい値を指定することになります。 |
114 | 99 | 指定しない場合には、多くのメソッドでは現在の値に対して何もしませんが、 |
115 | 100 | autoflush() では 1 を指定されたものとします。 |
116 | ||
117 | =begin original | |
118 | ||
119 | Because loading in the IO::Handle class is an expensive operation, you should | |
120 | learn how to use the regular built-in variables. | |
121 | ||
122 | =end original | |
123 | ||
124 | 101 | IO::Handle クラスを読み込むのはコストの高い操作なので、 |
125 | 102 | 通常の組み込み変数の使い方を覚えるべきです。 |
126 | 103 | |
127 | 104 | =begin original |
128 | 105 | |
129 | 106 | A few of these variables are considered "read-only". This means that if |
130 | 107 | you try to assign to this variable, either directly or indirectly through |
131 | 108 | a reference, you'll raise a run-time exception. |
132 | 109 | |
133 | 110 | =end original |
134 | 111 | |
135 | 112 | これらの変数の中には "read-only" として扱われるものもあります。 |
136 | 113 | つまり、そういった変数に対して、直接にしろ、リファレンスを |
137 | 114 | 介して間接にしろ、代入を行なおうとした場合には、実行時に |
138 | 115 | 例外処理が起動されます。 |
139 | 116 | |
140 | 117 | =begin original |
141 | 118 | |
142 | You should be very careful when modifying the default values of most | |
143 | special variables described in this document. In most cases you want | |
144 | to localize these variables before changing them, since if you don't, | |
145 | the change may affect other modules which rely on the default values | |
146 | of the special variables that you have changed. This is one of the | |
147 | correct ways to read the whole file at once: | |
148 | ||
149 | =end original | |
150 | ||
151 | この文書に記述されているほとんどの特殊変数のデフォルト値を変更するときには | |
152 | とても慎重になるべきです。 | |
153 | ほとんどの場合、これらの変数を変更する前にこれらをローカル化したいでしょう; | |
154 | さもなければ、あなたが変更した特殊変数のデフォルト値に依存している | |
155 | その他のモジュールにも影響を与えるかもしれないからです。 | |
156 | これはファイル全体を一度に読み込む正しい方法の一つです: | |
157 | ||
158 | open my $fh, "<", "foo" or die $!; | |
159 | local $/; # enable localized slurp mode | |
160 | my $content = <$fh>; | |
161 | close $fh; | |
162 | ||
163 | =begin original | |
164 | ||
165 | But the following code is quite bad: | |
166 | ||
167 | =end original | |
168 | ||
169 | しかし以下のコードは完全に悪いものです: | |
170 | ||
171 | open my $fh, "<", "foo" or die $!; | |
172 | undef $/; # enable slurp mode | |
173 | my $content = <$fh>; | |
174 | close $fh; | |
175 | ||
176 | =begin original | |
177 | ||
178 | since some other module, may want to read data from some file in the | |
179 | default "line mode", so if the code we have just presented has been | |
180 | executed, the global value of C<$/> is now changed for any other code | |
181 | running inside the same Perl interpreter. | |
182 | ||
183 | =end original | |
184 | ||
185 | なぜなら、その他のモジュールでは、デフォルトの「行モード」でファイルを | |
186 | 読もうとするかも知れませんが、もし単に前述のコードを実行すると、 | |
187 | C<$/> のグローバルな値が、同じ Perl インタプリタ内で実行される | |
188 | その他のコードに対しても変更されるからです。 | |
189 | ||
190 | =begin original | |
191 | ||
192 | Usually when a variable is localized you want to make sure that this | |
193 | change affects the shortest scope possible. So unless you are already | |
194 | inside some short C<{}> block, you should create one yourself. For | |
195 | example: | |
196 | ||
197 | =end original | |
198 | ||
199 | 通常、変数をローカル化するとき、この変更ができるだけ最短のスコープに | |
200 | 影響を与えることを確実にしたいでしょう。 | |
201 | 従って、既に小さい C<{}> ブロックの内側であるのでない限り、それを | |
202 | 自身で作るべきです。 | |
203 | 例えば: | |
204 | ||
205 | my $content = ''; | |
206 | open my $fh, "<", "foo" or die $!; | |
207 | { | |
208 | local $/; | |
209 | $content = <$fh>; | |
210 | } | |
211 | close $fh; | |
212 | ||
213 | =begin original | |
214 | ||
215 | Here is an example of how your own code can go broken: | |
216 | ||
217 | =end original | |
218 | ||
219 | 以下はどのように自分のコードが壊れるかの例です: | |
220 | ||
221 | for (1..5){ | |
222 | nasty_break(); | |
223 | print "$_ "; | |
224 | } | |
225 | sub nasty_break { | |
226 | $_ = 5; | |
227 | # do something with $_ | |
228 | } | |
229 | ||
230 | =begin original | |
231 | ||
232 | You probably expect this code to print: | |
233 | ||
234 | =end original | |
235 | ||
236 | おそらくこのコードは以下のように表示されることを期待しています: | |
237 | ||
238 | 1 2 3 4 5 | |
239 | ||
240 | =begin original | |
241 | ||
242 | but instead you get: | |
243 | ||
244 | =end original | |
245 | ||
246 | しかし、以下のようになります: | |
247 | ||
248 | 5 5 5 5 5 | |
249 | ||
250 | =begin original | |
251 | ||
252 | Why? Because nasty_break() modifies C<$_> without localizing it | |
253 | first. The fix is to add local(): | |
254 | ||
255 | =end original | |
256 | ||
257 | なぜでしょう? | |
258 | nasty_break() は C<$_> をローカル化する前に変更するからです。 | |
259 | 修正するには、local() を追加します: | |
260 | ||
261 | local $_ = 5; | |
262 | ||
263 | =begin original | |
264 | ||
265 | It's easy to notice the problem in such a short example, but in more | |
266 | complicated code you are looking for trouble if you don't localize | |
267 | changes to the special variables. | |
268 | ||
269 | =end original | |
270 | ||
271 | このような短い例では問題に気付くのは簡単ですが、より複雑なコードでは、 | |
272 | もし特殊変数の変更をローカル化していないと問題を探すことになります。 | |
273 | ||
274 | =begin original | |
275 | ||
276 | 119 | The following list is ordered by scalar variables first, then the |
277 | 120 | arrays, then the hashes. |
278 | 121 | |
279 | 122 | =end original |
280 | 123 | |
281 | 124 | 以下のリストはまずスカラ変数、それから配列、ハッシュの順に |
282 | 125 | 並んでいます。 |
283 | 126 | |
284 | 127 | =over 8 |
285 | 128 | |
286 | 129 | =item $ARG |
287 | 130 | |
288 | 131 | =item $_ |
289 | X<$_> X<$ARG> | |
290 | 132 | |
291 | 133 | =begin original |
292 | 134 | |
293 | 135 | The default input and pattern-searching space. The following pairs are |
294 | 136 | equivalent: |
295 | 137 | |
296 | 138 | =end original |
297 | 139 | |
298 | 140 | デフォルトの入力とパターン検索のスペース。 |
299 | 141 | 以下の 2つは同値です: |
300 | 142 | |
301 | 143 | while (<>) {...} # equivalent only in while! |
302 | 144 | while (defined($_ = <>)) {...} |
303 | 145 | |
304 | 146 | /^Subject:/ |
305 | 147 | $_ =~ /^Subject:/ |
306 | 148 | |
307 | 149 | tr/a-z/A-Z/ |
308 | 150 | $_ =~ tr/a-z/A-Z/ |
309 | 151 | |
310 | 152 | chomp |
311 | 153 | chomp($_) |
312 | 154 | |
313 | 155 | =begin original |
314 | 156 | |
315 | 157 | Here are the places where Perl will assume $_ even if you |
316 | 158 | don't use it: |
317 | 159 | |
318 | 160 | =end original |
319 | 161 | |
320 | Perl が(あなたが使いたくなくても) $_ を仮定する場合がいくつかあります | |
162 | Perl が(あなたが使いたくなくても) $_ を仮定する場合がいくつかあります。 | |
321 | 163 | |
322 | 164 | =over 3 |
323 | 165 | |
324 | 166 | =item * |
325 | 167 | |
326 | 168 | =begin original |
327 | 169 | |
328 | ||
170 | Various unary functions, including functions like ord() and int(), as well | |
171 | as the all file tests (C<-f>, C<-d>) except for C<-t>, which defaults to | |
172 | STDIN. | |
329 | 173 | |
330 | 174 | =end original |
331 | 175 | |
332 | 様々な関数 | |
176 | 様々な単項関数。ord() や int()、また C<-t> 以外の全ての | |
177 | ファイルテスト (C<-f>, C<-d>)など。C<-t> のデフォルトは STDIN です。 | |
333 | 178 | |
334 | =begin original | |
335 | ||
336 | abs, alarm, chomp, chop, chr, chroot, cos, defined, eval, exp, glob, | |
337 | hex, int, lc, lcfirst, length, log, lstat, mkdir, oct, ord, pos, print, | |
338 | quotemeta, readlink, readpipe, ref, require, reverse (in scalar context only), | |
339 | rmdir, sin, split (on its second argument), sqrt, stat, study, uc, ucfirst, | |
340 | unlink, unpack. | |
341 | ||
342 | =end original | |
343 | ||
344 | abs, alarm, chomp, chop, chr, chroot, cos, defined, eval, exp, glob, | |
345 | hex, int, lc, lcfirst, length, log, lstat, mkdir, oct, ord, pos, print, | |
346 | quotemeta, readlink, readpipe, ref, require, reverse (スカラコンテキストのみ), | |
347 | rmdir, sin, split (の 2 番目の引数), sqrt, stat, study, uc, ucfirst, | |
348 | unlink, unpack. | |
349 | ||
350 | 179 | =item * |
351 | 180 | |
352 | 181 | =begin original |
353 | 182 | |
354 | ||
183 | Various list functions like print() and unlink(). | |
355 | See L<perlfunc/-X> | |
356 | 184 | |
357 | 185 | =end original |
358 | 186 | |
359 | ||
187 | print() や unlink() などの様々なリスト関数。 | |
360 | L<perlfunc/-X> を参照してください。 | |
361 | 188 | |
362 | 189 | =item * |
363 | 190 | |
364 | 191 | =begin original |
365 | 192 | |
366 | The pattern matching operations C<m//>, C<s///> and C<tr///> | |
193 | The pattern matching operations C<m//>, C<s///>, and C<tr///> when used | |
367 | w | |
194 | without an C<=~> operator. | |
368 | 195 | |
369 | 196 | =end original |
370 | 197 | |
371 | C<=~> 演算子なしで用いられたパターンマッチ演算 C<m//>, C<s///>, C<tr///> | |
198 | C<=~> 演算子なしで用いられたパターンマッチ演算 C<m//>, C<s///>, C<tr///>。 | |
372 | (またの名を C<y///>)。 | |
373 | 199 | |
374 | 200 | =item * |
375 | 201 | |
376 | 202 | =begin original |
377 | 203 | |
378 | 204 | The default iterator variable in a C<foreach> loop if no other |
379 | 205 | variable is supplied. |
380 | 206 | |
381 | 207 | =end original |
382 | 208 | |
383 | 209 | C<foreach> ループでの他の変数が補われなかった場合のデフォルトの |
384 | 210 | 繰り返し変数。 |
385 | 211 | |
386 | 212 | =item * |
387 | 213 | |
388 | 214 | =begin original |
389 | 215 | |
390 | 216 | The implicit iterator variable in the grep() and map() functions. |
391 | 217 | |
392 | 218 | =end original |
393 | 219 | |
394 | 220 | grep() 関数と map() 関数の暗黙の繰り返し変数。 |
395 | 221 | |
396 | 222 | =item * |
397 | 223 | |
398 | 224 | =begin original |
399 | 225 | |
400 | The implicit variable of given(). | |
401 | ||
402 | =end original | |
403 | ||
404 | given() の暗黙の変数。 | |
405 | ||
406 | =item * | |
407 | ||
408 | =begin original | |
409 | ||
410 | 226 | The default place to put an input record when a C<< <FH> >> |
411 | 227 | operation's result is tested by itself as the sole criterion of a C<while> |
412 | 228 | test. Outside a C<while> test, this will not happen. |
413 | 229 | |
414 | 230 | =end original |
415 | 231 | |
416 | 232 | C<< <FH> >> が単独で C<while> テストでテストされた場合の |
417 | 233 | 結果を入れるデフォルトの場所。 |
418 | 234 | C<while> テスト以外ではこれは起こりません。 |
419 | 235 | |
420 | 236 | =back |
421 | 237 | |
422 | 238 | =begin original |
423 | 239 | |
424 | As C<$_> is a global variable, this may lead in some cases to unwanted | |
425 | side-effects. As of perl 5.9.1, you can now use a lexical version of | |
426 | C<$_> by declaring it in a file or in a block with C<my>. Moreover, | |
427 | declaring C<our $_> restores the global C<$_> in the current scope. | |
428 | ||
429 | =end original | |
430 | ||
431 | C<$_> はグローバル変数なので、望まないような副作用を引き起こす場合があります。 | |
432 | perl 5.9.1 から、ファイルやブロックで C<my> で宣言することで、 | |
433 | レキシカル版の C<$_> が使えます。 | |
434 | さらに、C<our $_> という宣言は現在のスコープでグローバルな C<$_> を | |
435 | 再構築します。 | |
436 | ||
437 | =begin original | |
438 | ||
439 | 240 | (Mnemonic: underline is understood in certain operations.) |
440 | 241 | |
441 | 242 | =end original |
442 | 243 | |
443 | 244 | (記憶法: 下線はある操作を覚えるためのもの。) |
444 | 245 | |
445 | 246 | =back |
446 | 247 | |
447 | 248 | =over 8 |
448 | 249 | |
449 | =item $a | |
450 | ||
451 | =item $b | |
452 | X<$a> X<$b> | |
453 | ||
454 | =begin original | |
455 | ||
456 | Special package variables when using sort(), see L<perlfunc/sort>. | |
457 | Because of this specialness $a and $b don't need to be declared | |
458 | (using use vars, or our()) even when using the C<strict 'vars'> pragma. | |
459 | Don't lexicalize them with C<my $a> or C<my $b> if you want to be | |
460 | able to use them in the sort() comparison block or function. | |
461 | ||
462 | =end original | |
463 | ||
464 | sort() を使うときの特殊パッケージ変数です; L<perlfunc/sort> を | |
465 | 参照してください。 | |
466 | この特殊性により、$a と $b は、たとえ C<strict 'vars'> を使っているときでも | |
467 | (use vars や our() を使って) 宣言する必要がありません。 | |
468 | これを sort() 比較ブロックや関数で使えるようにしたい場合は、 | |
469 | C<my $a> や C<my $b> としてレキシカル化しないでください。 | |
470 | ||
471 | =back | |
472 | ||
473 | =over 8 | |
474 | ||
475 | 250 | =item $<I<digits>> |
476 | X<$1> X<$2> X<$3> | |
477 | 251 | |
478 | 252 | =begin original |
479 | 253 | |
480 | 254 | Contains the subpattern from the corresponding set of capturing |
481 | 255 | parentheses from the last pattern match, not counting patterns |
482 | 256 | matched in nested blocks that have been exited already. (Mnemonic: |
483 | 257 | like \digits.) These variables are all read-only and dynamically |
484 | 258 | scoped to the current BLOCK. |
485 | 259 | |
486 | 260 | =end original |
487 | 261 | |
488 | 262 | 最後のパターンマッチで対応する括弧のサブパターンにマッチした |
489 | 263 | 文字列が入っているが、既に抜けてしまったブロックでの |
490 | 264 | パターンマッチは勘定に入れない。 |
491 | 265 | (記憶法: \(数字) のようなもの。) |
492 | 266 | これらの変数はすべて read-onlyで、現在の BLOCK に動的なスコープを持ちます。 |
493 | 267 | |
494 | 268 | =item $MATCH |
495 | 269 | |
496 | 270 | =item $& |
497 | X<$&> X<$MATCH> | |
498 | 271 | |
499 | 272 | =begin original |
500 | 273 | |
501 | 274 | The string matched by the last successful pattern match (not counting |
502 | 275 | any matches hidden within a BLOCK or eval() enclosed by the current |
503 | 276 | BLOCK). (Mnemonic: like & in some editors.) This variable is read-only |
504 | 277 | and dynamically scoped to the current BLOCK. |
505 | 278 | |
506 | 279 | =end original |
507 | 280 | |
508 | 281 | 最後に成功したパターンマッチでマッチした文字列 (現在の |
509 | 282 | BLOCK で囲まれた BLOCK や eval() で隠れている部分でのマッチは |
510 | 283 | 勘定に入れない)。 |
511 | 284 | (記憶法: あるエディタの & ようなもの。) |
512 | 285 | この変数は read-only で、現在の BLOCK に動的なスコープを持ちます。 |
513 | 286 | |
514 | 287 | =begin original |
515 | 288 | |
516 | 289 | The use of this variable anywhere in a program imposes a considerable |
517 | performance penalty on all regular expression matches. See L< | |
290 | performance penalty on all regular expression matches. See L<BUGS>. | |
518 | 291 | |
519 | 292 | =end original |
520 | 293 | |
521 | 294 | この変数をプログラムのどこかで使うと、プログラム中の全ての正規表現 |
522 | 295 | マッチングにおいてかなりの性能低下を引き起こします。 |
523 | L< | |
296 | L<BUGS> を参照して下さい。 | |
524 | 297 | |
525 | =begin original | |
526 | ||
527 | See L</@-> for a replacement. | |
528 | ||
529 | =end original | |
530 | ||
531 | 置き換えのためには L</@-> を参照してください。 | |
532 | ||
533 | =item ${^MATCH} | |
534 | X<${^MATCH}> | |
535 | ||
536 | =begin original | |
537 | ||
538 | This is similar to C<$&> (C<$MATCH>) except that it does not incur the | |
539 | performance penalty associated with that variable, and is only guaranteed | |
540 | to return a defined value when the pattern was compiled or executed with | |
541 | the C</p> modifier. | |
542 | ||
543 | =end original | |
544 | ||
545 | これは C<$&> (C<$MATCH>) と同様ですが、この変数と関連付けられた性能上の | |
546 | ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された | |
547 | 場合にのみ定義された値を返すことが保証されます。 | |
548 | ||
549 | 298 | =item $PREMATCH |
550 | 299 | |
551 | 300 | =item $` |
552 | X<$`> X<$PREMATCH> | |
553 | 301 | |
554 | 302 | =begin original |
555 | 303 | |
556 | 304 | The string preceding whatever was matched by the last successful |
557 | 305 | pattern match (not counting any matches hidden within a BLOCK or eval |
558 | 306 | enclosed by the current BLOCK). (Mnemonic: C<`> often precedes a quoted |
559 | 307 | string.) This variable is read-only. |
560 | 308 | |
561 | 309 | =end original |
562 | 310 | |
563 | 311 | 最後の成功したパターンマッチ (現在のBLOCK で囲まれた |
564 | 312 | BLOCK や eval() に隠れている部分でのマッチは勘定に入れない) で |
565 | 313 | マッチした部分の前の文字列。 |
566 | 314 | (記憶法: C<`> は多くの場合クォートされた文字列の前にある。) |
567 | 315 | この変数は read-only です。 |
568 | 316 | |
569 | 317 | =begin original |
570 | 318 | |
571 | 319 | The use of this variable anywhere in a program imposes a considerable |
572 | performance penalty on all regular expression matches. See L< | |
320 | performance penalty on all regular expression matches. See L<BUGS>. | |
573 | 321 | |
574 | 322 | =end original |
575 | 323 | |
576 | 324 | この変数をプログラムのどこかで使うと、プログラム中の全ての正規表現 |
577 | 325 | マッチングにおいてかなりの性能低下を引き起こします。 |
578 | L< | |
326 | L<BUGS> を参照して下さい。 | |
579 | 327 | |
580 | =begin original | |
581 | ||
582 | See L</@-> for a replacement. | |
583 | ||
584 | =end original | |
585 | ||
586 | 置き換えのためには L</@-> を参照してください。 | |
587 | ||
588 | =item ${^PREMATCH} | |
589 | X<${^PREMATCH}> | |
590 | ||
591 | =begin original | |
592 | ||
593 | This is similar to C<$`> ($PREMATCH) except that it does not incur the | |
594 | performance penalty associated with that variable, and is only guaranteed | |
595 | to return a defined value when the pattern was compiled or executed with | |
596 | the C</p> modifier. | |
597 | ||
598 | =end original | |
599 | ||
600 | これは C<$`> ($PREMATCH) と同様ですが、この変数と関連付けられた性能上の | |
601 | ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された | |
602 | 場合にのみ定義された値を返すことが保証されます。 | |
603 | ||
604 | 328 | =item $POSTMATCH |
605 | 329 | |
606 | 330 | =item $' |
607 | X<$'> X<$POSTMATCH> | |
608 | 331 | |
609 | 332 | =begin original |
610 | 333 | |
611 | 334 | The string following whatever was matched by the last successful |
612 | 335 | pattern match (not counting any matches hidden within a BLOCK or eval() |
613 | 336 | enclosed by the current BLOCK). (Mnemonic: C<'> often follows a quoted |
614 | 337 | string.) Example: |
615 | 338 | |
616 | 339 | =end original |
617 | 340 | |
618 | 341 | 最後の成功したパターンマッチ (現在のBLOCK で囲まれた |
619 | 342 | BLOCK や eval() に隠れている部分でのマッチは勘定に入れない) で |
620 | 343 | マッチした部分に続く文字列。 |
621 | 344 | (記憶法: C<'> は多くの場合クォートされた文字列の後にある。) 例: |
622 | 345 | |
623 | | |
346 | $_ = 'abcdefghi'; | |
624 | 347 | /def/; |
625 | 348 | print "$`:$&:$'\n"; # prints abc:def:ghi |
626 | 349 | |
627 | 350 | =begin original |
628 | 351 | |
629 | 352 | This variable is read-only and dynamically scoped to the current BLOCK. |
630 | 353 | |
631 | 354 | =end original |
632 | 355 | |
633 | 356 | この変数は read-only で、現在の BLOCK に動的なスコープを持ちます。 |
634 | 357 | |
635 | 358 | =begin original |
636 | 359 | |
637 | 360 | The use of this variable anywhere in a program imposes a considerable |
638 | performance penalty on all regular expression matches. See L< | |
361 | performance penalty on all regular expression matches. See L<BUGS>. | |
639 | 362 | |
640 | 363 | =end original |
641 | 364 | |
642 | 365 | この変数をプログラムのどこかで使うと、プログラム中の全ての正規表現 |
643 | 366 | マッチングにおいてかなりの性能低下を引き起こします。 |
644 | L< | |
367 | L<BUGS> を参照して下さい。 | |
645 | 368 | |
646 | =begin original | |
647 | ||
648 | See L</@-> for a replacement. | |
649 | ||
650 | =end original | |
651 | ||
652 | 置き換えのためには L</@-> を参照してください。 | |
653 | ||
654 | =item ${^POSTMATCH} | |
655 | X<${^POSTMATCH}> | |
656 | ||
657 | =begin original | |
658 | ||
659 | This is similar to C<$'> (C<$POSTMATCH>) except that it does not incur the | |
660 | performance penalty associated with that variable, and is only guaranteed | |
661 | to return a defined value when the pattern was compiled or executed with | |
662 | the C</p> modifier. | |
663 | ||
664 | =end original | |
665 | ||
666 | これは C<$'> (C<$POSTMATCH>) と同様ですが、この変数と関連付けられた性能上の | |
667 | ペナルティを被らず、パターンが C</p> 修飾子付きでコンパイルまたは実行された | |
668 | 場合にのみ定義された値を返すことが保証されます。 | |
669 | ||
670 | 369 | =item $LAST_PAREN_MATCH |
671 | 370 | |
672 | 371 | =item $+ |
673 | X<$+> X<$LAST_PAREN_MATCH> | |
674 | 372 | |
675 | 373 | =begin original |
676 | 374 | |
677 | The te | |
375 | The last bracket matched by the last search pattern. This is useful if | |
678 | ||
376 | you don't know which one of a set of alternative patterns matched. For | |
679 | ||
377 | example: | |
680 | 378 | |
681 | 379 | =end original |
682 | 380 | |
683 | 381 | 最後に検索されたパターンの最後の括弧にマッチした文字列。 |
684 | 382 | これはいくつかの選択肢の中でどれがマッチするのか |
685 | 383 | わからないような場合に使うと便利です。たとえば: |
686 | 384 | |
687 | 385 | /Version: (.*)|Revision: (.*)/ && ($rev = $+); |
688 | 386 | |
689 | 387 | =begin original |
690 | 388 | |
691 | 389 | (Mnemonic: be positive and forward looking.) |
692 | 390 | This variable is read-only and dynamically scoped to the current BLOCK. |
693 | 391 | |
694 | 392 | =end original |
695 | 393 | |
696 | 394 | (記憶法: ポジティブで前向き。) |
697 | 395 | この変数は read-only で、現在の BLOCK に動的なスコープを持ちます。 |
698 | 396 | |
699 | =item $LAST_SUBMATCH_RESULT | |
700 | ||
701 | =item $^N | |
702 | X<$^N> | |
703 | ||
704 | =begin original | |
705 | ||
706 | The text matched by the used group most-recently closed (i.e. the group | |
707 | with the rightmost closing parenthesis) of the last successful search | |
708 | pattern. (Mnemonic: the (possibly) Nested parenthesis that most | |
709 | recently closed.) | |
710 | ||
711 | =end original | |
712 | ||
713 | 最近のマッチングに成功した検索パターンのうち、一番最近に閉じられた | |
714 | 使われたグループ(つまり、一番右の閉じかっこのグループ)にマッチングした | |
715 | テキスト。 | |
716 | (記憶法: もっとも最近閉じられた、(おそらく) ネストした (Nested) かっこ。) | |
717 | ||
718 | =begin original | |
719 | ||
720 | This is primarily used inside C<(?{...})> blocks for examining text | |
721 | recently matched. For example, to effectively capture text to a variable | |
722 | (in addition to C<$1>, C<$2>, etc.), replace C<(...)> with | |
723 | ||
724 | =end original | |
725 | ||
726 | これは主として最近マッチしたテキストを調べるために C<(?{...})> ブロックの | |
727 | 中で使われます。 | |
728 | 例えば、(C<$1>, C<$2> などに加えて) テキストを変数に効率的に捕捉するには、 | |
729 | C<(...)> を以下で置き換えます: | |
730 | ||
731 | (?:(...)(?{ $var = $^N })) | |
732 | ||
733 | =begin original | |
734 | ||
735 | By setting and then using C<$var> in this way relieves you from having to | |
736 | worry about exactly which numbered set of parentheses they are. | |
737 | ||
738 | =end original | |
739 | ||
740 | C<$var> をこの方法で設定してから使うことで、かっこの組の番号について | |
741 | 気にしなくてすむようになります。 | |
742 | ||
743 | =begin original | |
744 | ||
745 | This variable is dynamically scoped to the current BLOCK. | |
746 | ||
747 | =end original | |
748 | ||
749 | この変数は現在の BLOCK に動的なスコープを持ちます。 | |
750 | ||
751 | 397 | =item @LAST_MATCH_END |
752 | 398 | |
753 | 399 | =item @+ |
754 | X<@+> X<@LAST_MATCH_END> | |
755 | 400 | |
756 | 401 | =begin original |
757 | 402 | |
758 | 403 | This array holds the offsets of the ends of the last successful |
759 | 404 | submatches in the currently active dynamic scope. C<$+[0]> is |
760 | 405 | the offset into the string of the end of the entire match. This |
761 | 406 | is the same value as what the C<pos> function returns when called |
762 | 407 | on the variable that was matched against. The I<n>th element |
763 | 408 | of this array holds the offset of the I<n>th submatch, so |
764 | 409 | C<$+[1]> is the offset past where $1 ends, C<$+[2]> the offset |
765 | 410 | past where $2 ends, and so on. You can use C<$#+> to determine |
766 | 411 | how many subgroups were in the last successful match. See the |
767 | 412 | examples given for the C<@-> variable. |
768 | 413 | |
769 | 414 | =end original |
770 | 415 | |
771 | 416 | この配列は、現在アクティブな動的スコープで最後に成功した |
772 | 417 | サブマッチの最後へのオフセットを保持します。 |
773 | 418 | C<$+[0]> はマッチ全体の文字列の最後へのオフセットです。 |
774 | 419 | これはマッチした変数に対して C<pos> 関数を呼び出したときの |
775 | 420 | 返り値と同じです。 |
776 | 421 | この配列の I<n> 番目の要素は I<n> 番目のサブマッチのオフセットを |
777 | 422 | 保持していますので、C<$+[1]> は過去の $1 の終わりのオフセット、 |
778 | 423 | C<$+[2]> は $2 のオフセット、という形になります。 |
779 | 424 | C<$#+> は最後に成功したマッチでいくつサブグループがあるかを |
780 | 425 | 決定するのに使えます。 |
781 | 426 | C<@-> 変数の例を参照して下さい。 |
782 | 427 | |
783 | =item | |
428 | =item $MULTILINE_MATCHING | |
784 | 429 | |
785 | =item | |
430 | =item $* | |
786 | X<%+> | |
787 | 431 | |
788 | 432 | =begin original |
789 | 433 | |
790 | S | |
434 | Set to a non-zero integer value to do multi-line matching within a | |
791 | ||
435 | string, 0 (or undefined) to tell Perl that it can assume that strings | |
792 | c | |
436 | contain a single line, for the purpose of optimizing pattern matches. | |
437 | Pattern matches on strings containing multiple newlines can produce | |
438 | confusing results when C<$*> is 0 or undefined. Default is undefined. | |
439 | (Mnemonic: * matches multiple things.) This variable influences the | |
440 | interpretation of only C<^> and C<$>. A literal newline can be searched | |
441 | for even when C<$* == 0>. | |
793 | 442 | |
794 | 443 | =end original |
795 | 444 | |
796 | ||
445 | 文字列中で複数行マッチを行なうために非ゼロに設定し、 | |
797 | ||
446 | 0 (または undef)にすると、Perl が文字列に 1 行しか無いと仮定して、 | |
447 | ある種のパターンマッチに関する最適化を行なうようになります。 | |
448 | 複数の改行を含む文字列でのパターンマッチを | |
449 | C<$*> が 0 または undef のまま行なうと結果は信用の | |
450 | ないものになります。 | |
451 | デフォルトでは undef になっています。 | |
452 | (記憶法: * は複数のものにマッチします。) | |
453 | この変数は C<^> と C<$> の解釈にのみ影響します。 | |
454 | リテラルの改行文字は、C<$* == 0> であっても検索することが可能です。 | |
798 | 455 | |
799 | 456 | =begin original |
800 | 457 | |
801 | ||
458 | Use of C<$*> is deprecated in modern Perl, supplanted by | |
459 | the C</s> and C</m> modifiers on pattern matching. | |
802 | 460 | |
803 | 461 | =end original |
804 | 462 | |
805 | ||
463 | 最近の Perl では "$*" を使わないようにしてください。 | |
464 | パターンマッチの C</s> と C</m> の修飾子に取って代わられています。 | |
806 | 465 | |
807 | 'foo' =~ /(?<foo>foo)/; | |
808 | ||
809 | 466 | =begin original |
810 | 467 | |
811 | ||
468 | Assigning a non-numerical value to C<$*> triggers a warning (and makes | |
812 | ||
469 | C<$*> act if C<$* == 0>), while assigning a numerical value to C<$*> | |
470 | makes that an implicit C<int> is applied on the value. | |
813 | 471 | |
814 | 472 | =end original |
815 | 473 | |
816 | C< | |
474 | 数値でない値を C<$*> に代入すると警告を引き起こします | |
817 | ||
475 | (そして C<$*> は C<$* == 0> のように振る舞います)。 | |
476 | 一方数値を C<$*> に代入すると暗黙に C<int> が値に適用されます。 | |
818 | 477 | |
819 | = | |
478 | =item input_line_number HANDLE EXPR | |
820 | 479 | |
821 | The underlying behaviour of C<%+> is provided by the | |
822 | L<Tie::Hash::NamedCapture> module. | |
823 | ||
824 | =end original | |
825 | ||
826 | C<%+> の基礎となる振る舞いは L<Tie::Hash::NamedCapture> モジュールで | |
827 | 提供されています。 | |
828 | ||
829 | =begin original | |
830 | ||
831 | B<Note:> C<%-> and C<%+> are tied views into a common internal hash | |
832 | associated with the last successful regular expression. Therefore mixing | |
833 | iterative access to them via C<each> may have unpredictable results. | |
834 | Likewise, if the last successful match changes, then the results may be | |
835 | surprising. | |
836 | ||
837 | =end original | |
838 | ||
839 | B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の | |
840 | 内部ハッシュと tie されたビューです。 | |
841 | 従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果と | |
842 | なります。 | |
843 | 同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。 | |
844 | ||
845 | =item HANDLE->input_line_number(EXPR) | |
846 | ||
847 | 480 | =item $INPUT_LINE_NUMBER |
848 | 481 | |
849 | 482 | =item $NR |
850 | 483 | |
851 | 484 | =item $. |
852 | X<$.> X<$NR> X<$INPUT_LINE_NUMBER> X<line number> | |
853 | 485 | |
854 | 486 | =begin original |
855 | 487 | |
856 | ||
488 | The current input record number for the last file handle from which | |
489 | you just read() (or called a C<seek> or C<tell> on). The value | |
490 | may be different from the actual physical line number in the file, | |
491 | depending on what notion of "line" is in effect--see C<$/> on how | |
492 | to change that. An explicit close on a filehandle resets the line | |
493 | number. Because C<< <> >> never does an explicit close, line | |
494 | numbers increase across ARGV files (but see examples in L<perlfunc/eof>). | |
495 | Consider this variable read-only: setting it does not reposition | |
496 | the seek pointer; you'll have to do that on your own. Localizing C<$.> | |
497 | has the effect of also localizing Perl's notion of "the last read | |
498 | filehandle". (Mnemonic: many programs use "." to mean the current line | |
499 | number.) | |
857 | 500 | |
858 | 501 | =end original |
859 | 502 | |
860 | 最後に | |
503 | 最後にread() (または C<seek> または C<tell>)を | |
504 | 行なったファイルハンドルの現在の入力レコード番号。 | |
862 | ||
505 | この値はファイルの実際の物理行番号とは異なるかもしれません。 | |
506 | 「行」とは何かによります。 | |
864 | ||
507 | これを変えるには C<$/> を参照して下さい。 | |
865 | ||
508 | 明示的にファイルハンドルをクローズした場合に、行番号がリセットされます。 | |
866 | ||
509 | C<< <> >> 構文では明示的にクローズを行ないませんから、ARGV の | |
867 | ||
510 | ファイルに跨って行番号が数えられることになります (が、 | |
868 | ||
511 | L<perlfunc/eof> の例を参照してください)。 | |
869 | ||
512 | この変数は読み込み専用と考えてください。 | |
513 | 値を設置してもシークポインタは移動しません。自力でする必要があります。 | |
871 | ||
514 | C<$.>を local 化すると、Perl の「最後に読んだファイルハンドル」を | |
515 | local 化する効果があります。 | |
873 | Perl の各ファイルハンドルは、そこから読み込んだ行数を数えています。 | |
874 | (C<$/> の値に依存して、何が行を構成するかに関する Perl の考えはあなたの | |
875 | 考えと一致しないかもしれません。) | |
876 | 行が(readline() や C<< <> >> を使って)ファイルハンドルから読み込まれたか、 | |
877 | tell() や seek() がファイルハンドルに対して呼び出された場合、 | |
878 | C<$.> はそのファイルハンドルの行カウンタへのエイリアスとなります。 | |
879 | ||
880 | =begin original | |
881 | ||
882 | You can adjust the counter by assigning to C<$.>, but this will not | |
883 | actually move the seek pointer. I<Localizing C<$.> will not localize | |
884 | the filehandle's line count>. Instead, it will localize perl's notion | |
885 | of which filehandle C<$.> is currently aliased to. | |
886 | ||
887 | =end original | |
888 | ||
889 | C<$.> へ代入することでカウンタの値を修正できますが、これは実際にシーク | |
890 | ポインタを動かすことはありません。 | |
891 | I<C<$.> をローカル化してもファイルハンドルの行カウンタは | |
892 | ローカル化されません>。 | |
893 | 代わりに、現在 C<$.> がどのファイルハンドルへのエイリアスかという情報が | |
894 | ローカル化されます。 | |
895 | ||
896 | =begin original | |
897 | ||
898 | C<$.> is reset when the filehandle is closed, but B<not> when an open | |
899 | filehandle is reopened without an intervening close(). For more | |
900 | details, see L<perlop/"IE<sol>O Operators">. Because C<< <> >> never does | |
901 | an explicit close, line numbers increase across ARGV files (but see | |
902 | examples in L<perlfunc/eof>). | |
903 | ||
904 | =end original | |
905 | ||
906 | C<$.> はファイルハンドルがクローズされるとリセットされますが、 | |
907 | オープンしているファイルハンドルが close() されることなく再オープンされた | |
908 | 場合にはリセット B<されません>。 | |
909 | さらなる詳細については、L<perlop/"IE<sol>O Operators"> を参照してください。 | |
910 | なぜなら、 C<< <> >> は決して明示的なクローズは行わず、行番号は ARGV の | |
911 | ファイル間で通算してカウントされるからです(但し L<perlfunc/eof> の例を | |
912 | 参照してください)。 | |
913 | ||
914 | =begin original | |
915 | ||
916 | You can also use C<< HANDLE->input_line_number(EXPR) >> to access the | |
917 | line counter for a given filehandle without having to worry about | |
918 | which handle you last accessed. | |
919 | ||
920 | =end original | |
921 | ||
922 | また、C<< HANDLE->input_line_number(EXPR) >> とすることで、どのハンドルに | |
923 | 最後にアクセスしたかを気にすることなく行カウンタにアクセスできます。 | |
924 | ||
925 | =begin original | |
926 | ||
927 | (Mnemonic: many programs use "." to mean the current line number.) | |
928 | ||
929 | =end original | |
930 | ||
931 | 516 | (記憶法: 多くのプログラムで "." が現在行番号を示すように使われています。) |
932 | 517 | |
933 | =item | |
518 | =item input_record_separator HANDLE EXPR | |
934 | 519 | |
935 | 520 | =item $INPUT_RECORD_SEPARATOR |
936 | 521 | |
937 | 522 | =item $RS |
938 | 523 | |
939 | 524 | =item $/ |
940 | X<$/> X<$RS> X<$INPUT_RECORD_SEPARATOR> | |
941 | 525 | |
942 | 526 | =begin original |
943 | 527 | |
944 | 528 | The input record separator, newline by default. This |
945 | 529 | influences Perl's idea of what a "line" is. Works like B<awk>'s RS |
946 | 530 | variable, including treating empty lines as a terminator if set to |
947 | 531 | the null string. (An empty line cannot contain any spaces |
948 | 532 | or tabs.) You may set it to a multi-character string to match a |
949 | 533 | multi-character terminator, or to C<undef> to read through the end |
950 | 534 | of file. Setting it to C<"\n\n"> means something slightly |
951 | 535 | different than setting to C<"">, if the file contains consecutive |
952 | 536 | empty lines. Setting to C<""> will treat two or more consecutive |
953 | 537 | empty lines as a single empty line. Setting to C<"\n\n"> will |
954 | 538 | blindly assume that the next input character belongs to the next |
955 | 539 | paragraph, even if it's a newline. (Mnemonic: / delimits |
956 | 540 | line boundaries when quoting poetry.) |
957 | 541 | |
958 | 542 | =end original |
959 | 543 | |
960 | 544 | 入力レコードセパレータで、デフォルトでは改行文字。 |
961 | 545 | これは Perl での「行」とは何か、ということに影響を与えます。 |
962 | 546 | 空文字列に設定されると、空行をセパレータとして扱うことを |
963 | 547 | 含めて、B<awk> の変数 RS のように働きます |
964 | 548 | (空行はスペースやタブを含んでいてはいけません)。 |
965 | 549 | 複数文字の区切文字を示すために、文字列を設定することもできます。 |
966 | 550 | また、ファイルの最後まで読み込むために undef を指定することもできます。 |
967 | 551 | この変数に C<"\n\n"> を設定すると、空行が続く場合において、 |
968 | 552 | C<""> を設定した場合とわずかに違う動作をするようになります。 |
969 | 553 | C<""> を設定した場合には、複数の空行も 1 つの空行であるかのように扱います。 |
970 | 554 | C<"\n\n"> を設定した場合には、単純に次の文字が (たとえ改行文字であっても) |
971 | 555 | 次の段落に含まれるものとして扱います。 |
972 | 556 | (記憶法: /は、詩を引用するときに、行の区切りを示します。) |
973 | 557 | |
974 | | |
558 | undef $/; # enable "slurp" mode | |
975 | | |
559 | $_ = <FH>; # whole file now here | |
976 | 560 | s/\n[ \t]+/ /g; |
977 | 561 | |
978 | 562 | =begin original |
979 | 563 | |
980 | 564 | Remember: the value of C<$/> is a string, not a regex. B<awk> has to be |
981 | 565 | better for something. :-) |
982 | 566 | |
983 | 567 | =end original |
984 | 568 | |
985 | 569 | 注意: C<$/> は文字列であり、正規表現ではありません。 |
986 | 570 | B<awk> は何かもっとうまくやらなくてはいけません。:-) |
987 | 571 | |
988 | 572 | =begin original |
989 | 573 | |
990 | 574 | Setting C<$/> to a reference to an integer, scalar containing an integer, or |
991 | 575 | scalar that's convertible to an integer will attempt to read records |
992 | 576 | instead of lines, with the maximum record size being the referenced |
993 | 577 | integer. So this: |
994 | 578 | |
995 | 579 | =end original |
996 | 580 | |
997 | 581 | C<$/> に整数、整数を含むスカラ、整数に変換できるスカラのいずれかへの |
998 | 582 | リファレンスをセットすると、行を読む代わりにレコードを読もうとします。 |
999 | 583 | この場合、最大レコードサイズはリファレンス先の整数値となります。つまり: |
1000 | 584 | |
1001 | | |
585 | $/ = \32768; # or \"32768", or \$var_containing_32768 | |
1002 | open | |
586 | open(FILE, $myfile); | |
1003 | | |
587 | $_ = <FILE>; | |
1004 | 588 | |
1005 | 589 | =begin original |
1006 | 590 | |
1007 | 591 | will read a record of no more than 32768 bytes from FILE. If you're |
1008 | 592 | not reading from a record-oriented file (or your OS doesn't have |
1009 | 593 | record-oriented files), then you'll likely get a full chunk of data |
1010 | 594 | with every read. If a record is larger than the record size you've |
1011 | set, you'll get the record back in pieces. | |
595 | set, you'll get the record back in pieces. | |
1012 | size to zero or less will cause reading in the (rest of the) whole file. | |
1013 | 596 | |
1014 | 597 | =end original |
1015 | 598 | |
1016 | 599 | これは FILE から 32768 バイトを超えないようにレコードを読み込みます。 |
1017 | 600 | もしレコード指向のファイルを読み込まない場合 |
1018 | 601 | (あるいは OS がレコード指向ファイルを持たない場合)、 |
1019 | 602 | 読み込み毎にデータのチャンク全部を取り込みます。 |
1020 | 603 | もしレコードがセットしたレコードサイズより大きい場合、 |
1021 | 604 | レコードの部分を取り込みます。 |
1022 | レコードサイズを 0 以下にセットしようとすると、(残りの)ファイル全体を | |
1023 | 読み込むことになります。 | |
1024 | 605 | |
1025 | 606 | =begin original |
1026 | 607 | |
1027 | 608 | On VMS, record reads are done with the equivalent of C<sysread>, |
1028 | 609 | so it's best not to mix record and non-record reads on the same |
1029 | 610 | file. (This is unlikely to be a problem, because any file you'd |
1030 | 611 | want to read in record mode is probably unusable in line mode.) |
1031 | 612 | Non-VMS systems do normal I/O, so it's safe to mix record and |
1032 | 613 | non-record reads of a file. |
1033 | 614 | |
1034 | 615 | =end original |
1035 | 616 | |
1036 | 617 | VMS では、レコード読み込みは C<sysread> と等価に行われますので、 |
1037 | 618 | レコード読み込みと非レコード読み込みを同じファイルで混ぜないのが |
1038 | 619 | 最善です。(これはあまり問題になりません。なぜなら |
1039 | 620 | レコード読み込みしたいファイルは多分行モードでは使えないものだからです。) |
1040 | 621 | VMS 以外のシステムでは普通の I/O を使いますので、 |
1041 | 622 | 同じファイルのレコード読み込みと非レコード読み込みを混ぜても安全です。 |
1042 | 623 | |
1043 | 624 | =begin original |
1044 | 625 | |
1045 | 626 | See also L<perlport/"Newlines">. Also see C<$.>. |
1046 | 627 | |
1047 | 628 | =end original |
1048 | 629 | |
1049 | 630 | L<perlport/"Newlines"> と C<$.> も参照してください。 |
1050 | 631 | |
1051 | =item | |
632 | =item autoflush HANDLE EXPR | |
1052 | 633 | |
1053 | 634 | =item $OUTPUT_AUTOFLUSH |
1054 | 635 | |
1055 | 636 | =item $| |
1056 | X<$|> X<autoflush> X<flush> X<$OUTPUT_AUTOFLUSH> | |
1057 | 637 | |
1058 | 638 | =begin original |
1059 | 639 | |
1060 | 640 | If set to nonzero, forces a flush right away and after every write |
1061 | 641 | or print on the currently selected output channel. Default is 0 |
1062 | 642 | (regardless of whether the channel is really buffered by the |
1063 | 643 | system or not; C<$|> tells you only whether you've asked Perl |
1064 | 644 | explicitly to flush after each write). STDOUT will |
1065 | 645 | typically be line buffered if output is to the terminal and block |
1066 | 646 | buffered otherwise. Setting this variable is useful primarily when |
1067 | 647 | you are outputting to a pipe or socket, such as when you are running |
1068 | 648 | a Perl program under B<rsh> and want to see the output as it's |
1069 | 649 | happening. This has no effect on input buffering. See L<perlfunc/getc> |
1070 | for that. | |
650 | for that. (Mnemonic: when you want your pipes to be piping hot.) | |
1071 | See also L<IO::Handle>. (Mnemonic: when you want your pipes to be piping hot.) | |
1072 | 651 | |
1073 | 652 | =end original |
1074 | 653 | |
1075 | 654 | 0 以外に設定されると、 |
1076 | 655 | その時点で選択されている出力チャネルを |
1077 | 656 | 直ちにその場でフラッシュし、 |
1078 | 657 | さらに write や print を行なうごとに、強制的にフラッシュします。 |
1079 | 658 | デフォルトでは 0 となっています |
1080 | 659 | (チャンネルが実際にシステムによってバッファリングされているかどうかは |
1081 | 660 | 関知しません。C<$|> は Perl が明示的に毎回書き込みの後に |
1082 | 661 | フラッシュするかどうかのみを示します)。 |
1083 | 662 | STDOUT は通常では、端末への出力時には行バッファリング、 |
1084 | 663 | それ以外ではブロックバッファリングであることに注意してください。 |
1085 | 664 | これは、Perl のスクリプトを rsh 配下で実行して、 |
1086 | 実行状況を確認したい場合のように、パイプやソケットに出力するときに特に | |
665 | 実行状況を確認したい場合のように、パイプやソケットに出力するときに特に便利でしょう。 | |
1087 | 便利でしょう。 | |
1088 | 666 | これは入力バッファリングには何の影響も与えません。 |
1089 | 出力チャネルの選択方法については L<perldoc/select> を参照してください。 | |
1090 | L<IO::Handle> も参照してください。 | |
1091 | 667 | (記憶法: パイプをホットな状態にしておくために使う。) |
1092 | 668 | |
1093 | =item | |
669 | =item output_field_separator HANDLE EXPR | |
1094 | 670 | |
1095 | 671 | =item $OUTPUT_FIELD_SEPARATOR |
1096 | 672 | |
1097 | 673 | =item $OFS |
1098 | 674 | |
1099 | 675 | =item $, |
1100 | X<$,> X<$OFS> X<$OUTPUT_FIELD_SEPARATOR> | |
1101 | 676 | |
1102 | 677 | =begin original |
1103 | 678 | |
1104 | The output field separator for the print operator. | |
679 | The output field separator for the print operator. Ordinarily the | |
1105 | ||
680 | print operator simply prints out its arguments without further | |
1106 | ||
681 | adornment. To get behavior more like B<awk>, set this variable as | |
682 | you would set B<awk>'s OFS variable to specify what is printed | |
683 | between fields. (Mnemonic: what is printed when there is a "," in | |
684 | your print statement.) | |
1107 | 685 | |
1108 | 686 | =end original |
1109 | 687 | |
1110 | 688 | print 演算子のための出力フィールドセパレータ。 |
1111 | ||
689 | 通常 print 演算子は、引数を修飾なしで単純に印字します。 | |
1112 | ||
690 | より、B<awk> に近い動作をさせるには、 | |
691 | フィールドの区切りとして印字されるものとして B<awk> の | |
692 | 変数 OFS に設定するものを、この変数に設定します。 | |
1113 | 693 | (記憶法: print 文で "," を書いた場所に印字されるもの。) |
1114 | 694 | |
1115 | =item | |
695 | =item output_record_separator HANDLE EXPR | |
1116 | 696 | |
1117 | 697 | =item $OUTPUT_RECORD_SEPARATOR |
1118 | 698 | |
1119 | 699 | =item $ORS |
1120 | 700 | |
1121 | 701 | =item $\ |
1122 | X<$\> X<$ORS> X<$OUTPUT_RECORD_SEPARATOR> | |
1123 | 702 | |
1124 | 703 | =begin original |
1125 | 704 | |
1126 | The output record separator for the print operator. | |
705 | The output record separator for the print operator. Ordinarily the | |
1127 | ||
706 | print operator simply prints out its arguments as is, with no | |
1128 | ||
707 | trailing newline or other end-of-record string added. To get | |
1129 | ||
708 | behavior more like B<awk>, set this variable as you would set | |
709 | B<awk>'s ORS variable to specify what is printed at the end of the | |
710 | print. (Mnemonic: you set C<$\> instead of adding "\n" at the | |
711 | end of the print. Also, it's just like C<$/>, but it's what you | |
712 | get "back" from Perl.) | |
1130 | 713 | |
1131 | 714 | =end original |
1132 | 715 | |
1133 | 716 | print 演算子のための出力レコードセパレータ。 |
1134 | ||
717 | 通常print 演算子は、引数を単純に印字し、 | |
1135 | ||
718 | 改行などレコード終わりの文字列をつけません。 | |
719 | より B<awk> に近い動作をさせるには、 | |
720 | print の最後に印字されるものとして B<awk> の変数 ORS に | |
721 | 設定するものを、この変数に設定します。 | |
1136 | 722 | (記憶法: print の最後に "\n" を付け加える代わりに C<$\> を設定する。 |
1137 | 723 | また、C<$/> に似通っているが、Perl から「バック」されるものです。) |
1138 | 724 | |
1139 | 725 | =item $LIST_SEPARATOR |
1140 | 726 | |
1141 | 727 | =item $" |
1142 | X<$"> X<$LIST_SEPARATOR> | |
1143 | 728 | |
1144 | 729 | =begin original |
1145 | 730 | |
1146 | 731 | This is like C<$,> except that it applies to array and slice values |
1147 | 732 | interpolated into a double-quoted string (or similar interpreted |
1148 | 733 | string). Default is a space. (Mnemonic: obvious, I think.) |
1149 | 734 | |
1150 | 735 | =end original |
1151 | 736 | |
1152 | 737 | C<$,> と同様ですが、これは 2 重引用符で括られた文字列 |
1153 | 738 | (または、同様に扱われる文字列) 内で配列とスライスの値が展開される |
1154 | 739 | 際に適用されます。 |
1155 | 740 | デフォルトではスペースになっています。(記憶法: 明らかでしょう。) |
1156 | 741 | |
1157 | 742 | =item $SUBSCRIPT_SEPARATOR |
1158 | 743 | |
1159 | 744 | =item $SUBSEP |
1160 | 745 | |
1161 | 746 | =item $; |
1162 | X<$;> X<$SUBSEP> X<SUBSCRIPT_SEPARATOR> | |
1163 | 747 | |
1164 | 748 | =begin original |
1165 | 749 | |
1166 | 750 | The subscript separator for multidimensional array emulation. If you |
1167 | 751 | refer to a hash element as |
1168 | 752 | |
1169 | =end original | |
1170 | ||
1171 | 多次元配列のエミュレートのための添え字の区切文字。 | |
1172 | ハッシュの要素を | |
1173 | ||
1174 | 753 | $foo{$a,$b,$c} |
1175 | 754 | |
1176 | =begin original | |
1177 | ||
1178 | 755 | it really means |
1179 | 756 | |
1180 | ||
757 | $foo{join($;, $a, $b, $c)} | |
1181 | 758 | |
1182 | ||
759 | But don't put | |
1183 | 760 | |
1184 | | |
761 | @foo{$a,$b,$c} # a slice--note the @ | |
1185 | 762 | |
1186 | ||
763 | which means | |
1187 | 764 | |
1188 | ||
765 | ($foo{$a},$foo{$b},$foo{$c}) | |
1189 | 766 | |
1190 | 767 | =end original |
1191 | 768 | |
1192 | ||
769 | 多次元配列のエミュレートのための添え字の区切文字。 | |
1193 | ||
770 | ハッシュの要素を | |
1194 | 771 | |
1195 | | |
772 | $foo{$a,$b,$c} | |
1196 | 773 | |
1197 | ||
774 | のようにして参照すると、実際には | |
1198 | 775 | |
1199 | ||
776 | $foo{join($;, $a, $b, $c)} | |
1200 | 777 | |
1201 | ||
778 | という意味になります。 しかし、 | |
1202 | 779 | |
1203 | ||
780 | @foo{$a,$b,$c} # スライス -- @ に注意 | |
1204 | これは以下の意味になります。 | |
1205 | 781 | |
782 | としてはいけません。これは以下の意味になります。 | |
783 | ||
1206 | 784 | ($foo{$a},$foo{$b},$foo{$c}) |
1207 | 785 | |
1208 | 786 | =begin original |
1209 | 787 | |
1210 | 788 | Default is "\034", the same as SUBSEP in B<awk>. If your |
1211 | 789 | keys contain binary data there might not be any safe value for C<$;>. |
1212 | 790 | (Mnemonic: comma (the syntactic subscript separator) is a |
1213 | 791 | semi-semicolon. Yeah, I know, it's pretty lame, but C<$,> is already |
1214 | 792 | taken for something more important.) |
1215 | 793 | |
1216 | 794 | =end original |
1217 | 795 | |
1218 | 796 | デフォルトは "\034" で、C<awk> の SUBSEP と同じです。 |
1219 | 797 | 使おうとしている key の値がバイナリのデータを含むならば、 |
1220 | 798 | C<$;> に設定する安全な値などはないことになります。 |
1221 | 799 | (記憶法: コンマ (構文上の添え字区切り文字) は |
1222 | 800 | セミ−セミコロンなのです。 |
1223 | 801 | ええ、詭弁だとはわかってますが、C<$,> はもう既にもっと |
1224 | 802 | 重要な任務を持ってるんです。) |
1225 | 803 | |
1226 | 804 | =begin original |
1227 | 805 | |
1228 | 806 | Consider using "real" multidimensional arrays as described |
1229 | 807 | in L<perllol>. |
1230 | 808 | |
1231 | 809 | =end original |
1232 | 810 | |
1233 | 811 | L<perllol> で記述している「本物の」多次元配列を使うようにしてください。 |
1234 | 812 | |
1235 | =item | |
813 | =item $OFMT | |
1236 | 814 | |
815 | =item $# | |
816 | ||
817 | =begin original | |
818 | ||
819 | The output format for printed numbers. This variable is a half-hearted | |
820 | attempt to emulate B<awk>'s OFMT variable. There are times, however, | |
821 | when B<awk> and Perl have differing notions of what counts as | |
822 | numeric. The initial value is "%.I<n>g", where I<n> is the value | |
823 | of the macro DBL_DIG from your system's F<float.h>. This is different from | |
824 | B<awk>'s default OFMT setting of "%.6g", so you need to set C<$#> | |
825 | explicitly to get B<awk>'s value. (Mnemonic: # is the number sign.) | |
826 | ||
827 | =end original | |
828 | ||
829 | 数字を印字する際の出力フォーマット。 | |
830 | この変数は、不十分ではありますが、B<awk> の変数 OFMT を | |
831 | エミュレートしようとするものです。 | |
832 | しかしながら、B<awk> と Perl は異なる記法で数値を表わしています。 | |
833 | また、初期値は"%.I<n>g" で、ここで I<n> はシステムの F<float.h> で | |
834 | 定義されているマクロ DBL_DIG の値です。 | |
835 | これはB<awk> のOFMT のデフォルト値である "%.6g" と異なっていますので、 | |
836 | awk での値を得るには、明示的に C<$#> を設定する必要があります。 | |
837 | (記憶法: # は数値記号です。) | |
838 | ||
839 | =begin original | |
840 | ||
841 | Use of C<$#> is deprecated. | |
842 | ||
843 | =end original | |
844 | ||
845 | C<$#> は古いものなので使わないようにしてください。 | |
846 | ||
847 | =item format_page_number HANDLE EXPR | |
848 | ||
1237 | 849 | =item $FORMAT_PAGE_NUMBER |
1238 | 850 | |
1239 | 851 | =item $% |
1240 | X<$%> X<$FORMAT_PAGE_NUMBER> | |
1241 | 852 | |
1242 | 853 | =begin original |
1243 | 854 | |
1244 | 855 | The current page number of the currently selected output channel. |
1245 | 856 | Used with formats. |
1246 | 857 | (Mnemonic: % is page number in B<nroff>.) |
1247 | 858 | |
1248 | 859 | =end original |
1249 | 860 | |
1250 | 861 | その時点で選択されている出力チャネルの、その時点でのページ番号。 |
1251 | 862 | フォーマットで用いられます。 |
1252 | 863 | (記憶法: % は、B<nroff> でのページ番号です。) |
1253 | 864 | |
1254 | =item | |
865 | =item format_lines_per_page HANDLE EXPR | |
1255 | 866 | |
1256 | 867 | =item $FORMAT_LINES_PER_PAGE |
1257 | 868 | |
1258 | 869 | =item $= |
1259 | X<$=> X<$FORMAT_LINES_PER_PAGE> | |
1260 | 870 | |
1261 | 871 | =begin original |
1262 | 872 | |
1263 | 873 | The current page length (printable lines) of the currently selected |
1264 | 874 | output channel. Default is 60. |
1265 | 875 | Used with formats. |
1266 | 876 | (Mnemonic: = has horizontal lines.) |
1267 | 877 | |
1268 | 878 | =end original |
1269 | 879 | |
1270 | 880 | その時点で選択されている出力チャネルの、その時点での |
1271 | 881 | ページ長 (印字可能行数)。デフォルトは 60 です。 |
1272 | 882 | フォーマットで用いられます。 |
1273 | 883 | (記憶法: = には複数の水平線 (行) が含まれます。) |
1274 | 884 | |
1275 | =item | |
885 | =item format_lines_left HANDLE EXPR | |
1276 | 886 | |
1277 | 887 | =item $FORMAT_LINES_LEFT |
1278 | 888 | |
1279 | 889 | =item $- |
1280 | X<$-> X<$FORMAT_LINES_LEFT> | |
1281 | 890 | |
1282 | 891 | =begin original |
1283 | 892 | |
1284 | 893 | The number of lines left on the page of the currently selected output |
1285 | 894 | channel. |
1286 | 895 | Used with formats. |
1287 | 896 | (Mnemonic: lines_on_page - lines_printed.) |
1288 | 897 | |
1289 | 898 | =end original |
1290 | 899 | |
1291 | 900 | その時点で選択されている出力チャネルの、ページに残っている行数。 |
1292 | 901 | フォーマットで用いられます。 |
1293 | 902 | (記憶法: "ページ行数" - "印字済み行数") |
1294 | 903 | |
1295 | 904 | =item @LAST_MATCH_START |
1296 | 905 | |
1297 | 906 | =item @- |
1298 | X<@-> X<@LAST_MATCH_START> | |
1299 | 907 | |
1300 | 908 | =begin original |
1301 | 909 | |
1302 | 910 | $-[0] is the offset of the start of the last successful match. |
1303 | 911 | C<$-[>I<n>C<]> is the offset of the start of the substring matched by |
1304 | 912 | I<n>-th subpattern, or undef if the subpattern did not match. |
1305 | 913 | |
1306 | 914 | =end original |
1307 | 915 | |
1308 | 916 | $-[0] は最後に成功したマッチの先頭のオフセットです。 |
1309 | 917 | C<$-[>I<n>C<]> は I<n> 番目のサブパターンにマッチした部分文字列の |
1310 | 918 | 先頭のオフセットです。サブパターンがマッチしなかった場合は undef です。 |
1311 | 919 | |
1312 | 920 | =begin original |
1313 | 921 | |
1314 | 922 | Thus after a match against $_, $& coincides with C<substr $_, $-[0], |
1315 | $+[0] - $-[0]>. Similarly, $I<n> coincides with C<substr $_, $-[n], | |
923 | $+[0] - $-[0]>. Similarly, C<$>I<n> coincides with C<substr $_, $-[>I<n>C<], | |
1316 | $+[n] - $-[n]> if C<$-[n]> is defined, and $+ coincides with | |
924 | $+[>I<n>C<] - $-[>I<n>C<]> if C<$-[>I<n>C<]> is defined, and $+ coincides with | |
1317 | C<substr $_, $-[$#-], $+[$#-] | |
925 | C<substr $_, $-[$#-], $+[$#-]>. One can use C<$#-> to find the last | |
1318 | 926 | matched subgroup in the last successful match. Contrast with |
1319 | 927 | C<$#+>, the number of subgroups in the regular expression. Compare |
1320 | 928 | with C<@+>. |
1321 | 929 | |
1322 | 930 | =end original |
1323 | 931 | |
1324 | 932 | 従って $_ のマッチの後、$& は C<substr $_, $-[0], $+[0] - $-[0]> と |
1325 | 一致します。同様に、$I<n> は、C<$-[n]> が定義されていれば | |
933 | 一致します。同様に、C<$>I<n> は、C<$-[>I<n>C<]> が定義されていれば | |
1326 | C<substr $_, $-[n], $+[n] - $-[n]> と一致し、 | |
934 | C<substr $_, $-[>I<n>C<], $+[>I<n>C<] - $-[>I<n>C<]> と一致し、 | |
1327 | $+ は C<substr $_, $-[$#-], $+[$#-] | |
935 | $+ は C<substr $_, $-[$#-], $+[$#-]> と一致します。 | |
1328 | 936 | C<$#-> は直前に成功したマッチで最後のマッチしたサブグループを |
1329 | 937 | 探すのに使えます。 |
1330 | 938 | 正規表現でのサブグループの数である C<$#+> と対照的です。 |
1331 | 939 | C<@+> と比較してください。 |
1332 | 940 | |
1333 | 941 | =begin original |
1334 | 942 | |
1335 | 943 | This array holds the offsets of the beginnings of the last |
1336 | 944 | successful submatches in the currently active dynamic scope. |
1337 | 945 | C<$-[0]> is the offset into the string of the beginning of the |
1338 | 946 | entire match. The I<n>th element of this array holds the offset |
1339 | of the I<n>th submatch, so C<$ | |
947 | of the I<n>th submatch, so C<$+[1]> is the offset where $1 | |
1340 | begins, C<$ | |
948 | begins, C<$+[2]> the offset where $2 begins, and so on. | |
949 | You can use C<$#-> to determine how many subgroups were in the | |
950 | last successful match. Compare with the C<@+> variable. | |
1341 | 951 | |
1342 | 952 | =end original |
1343 | 953 | |
1344 | 954 | この配列は現在アクティブな動的スコープ内で最後に成功した |
1345 | 955 | サブマッチの先頭位置のオフセットを保持します。 |
1346 | 956 | C<$-[0]> はマッチ全体の先頭の文字列へのオフセットです。 |
1347 | 957 | この配列の I<n> 番目の要素は I<n> 番目のサブマッチへの |
1348 | オフセットを保持しますので、C<$ | |
958 | オフセットを保持しますので、C<$+[1]> は $1 の先頭への | |
1349 | オフセット、C<$ | |
959 | オフセット、C<$+[2]> は $2 の先頭へのオフセット、などとなります。 | |
960 | C<$#-> を、最後に成功したマッチでいくつのサブグループがあるのかを | |
961 | 決定するのに使えます。 | |
962 | C<@+> 変数と比較してください。 | |
1350 | 963 | |
1351 | 964 | =begin original |
1352 | 965 | |
1353 | 966 | After a match against some variable $var: |
1354 | 967 | |
1355 | 968 | =end original |
1356 | 969 | |
1357 | 970 | ある変数 $var でマッチした後、以下のようになります。 |
1358 | 971 | |
1359 | 972 | =begin original |
1360 | 973 | |
1361 | 974 | =over 5 |
1362 | 975 | |
1363 | 976 | =item C<$`> is the same as C<substr($var, 0, $-[0])> |
1364 | 977 | |
1365 | 978 | =item C<$&> is the same as C<substr($var, $-[0], $+[0] - $-[0])> |
1366 | 979 | |
1367 | 980 | =item C<$'> is the same as C<substr($var, $+[0])> |
1368 | 981 | |
1369 | 982 | =item C<$1> is the same as C<substr($var, $-[1], $+[1] - $-[1])> |
1370 | 983 | |
1371 | 984 | =item C<$2> is the same as C<substr($var, $-[2], $+[2] - $-[2])> |
1372 | 985 | |
1373 | =item C<$3> is the same as C<substr | |
986 | =item C<$3> is the same as C<substr $var, $-[3], $+[3] - $-[3])> | |
1374 | 987 | |
1375 | 988 | =back |
1376 | 989 | |
1377 | 990 | =end original |
1378 | 991 | |
1379 | 992 | =over 5 |
1380 | 993 | |
1381 | 994 | =item C<$`> は C<substr($var, 0, $-[0])> と同じです。 |
1382 | 995 | |
1383 | 996 | =item C<$&> は C<substr($var, $-[0], $+[0] - $-[0])> と同じです。 |
1384 | 997 | |
1385 | 998 | =item C<$'> は C<substr($var, $+[0])> と同じです。 |
1386 | 999 | |
1387 | 1000 | =item C<$1> は C<substr($var, $-[1], $+[1] - $-[1])> と同じです。 |
1388 | 1001 | |
1389 | 1002 | =item C<$2> は C<substr($var, $-[2], $+[2] - $-[2])> と同じです。 |
1390 | 1003 | |
1391 | 1004 | =item C<$3> は C<substr $var, $-[3], $+[3] - $-[3])> と同じです。 |
1392 | 1005 | |
1393 | 1006 | =back |
1394 | 1007 | |
1395 | =item | |
1008 | =item format_name HANDLE EXPR | |
1396 | X<%-> | |
1397 | 1009 | |
1398 | =begin original | |
1399 | ||
1400 | Similar to C<%+>, this variable allows access to the named capture buffers | |
1401 | in the last successful match in the currently active dynamic scope. To | |
1402 | each capture buffer name found in the regular expression, it associates a | |
1403 | reference to an array containing the list of values captured by all | |
1404 | buffers with that name (should there be several of them), in the order | |
1405 | where they appear. | |
1406 | ||
1407 | =end original | |
1408 | ||
1409 | C<%+> と同様、この変数は現在アクティブな動的スコープで最後に成功した | |
1410 | マッチングの名前付き捕捉バッファへのアクセスを可能にします。 | |
1411 | 正規表現中に捕捉バッファ名が現れるごとに、その名前のバッファ全てで | |
1412 | (複数あるでしょう)捕捉されている値のリストを出現順で含む配列への | |
1413 | リファレンスと関連付けられます。 | |
1414 | ||
1415 | =begin original | |
1416 | ||
1417 | Here's an example: | |
1418 | ||
1419 | =end original | |
1420 | ||
1421 | 以下に例を示します: | |
1422 | ||
1423 | if ('1234' =~ /(?<A>1)(?<B>2)(?<A>3)(?<B>4)/) { | |
1424 | foreach my $bufname (sort keys %-) { | |
1425 | my $ary = $-{$bufname}; | |
1426 | foreach my $idx (0..$#$ary) { | |
1427 | print "\$-{$bufname}[$idx] : ", | |
1428 | (defined($ary->[$idx]) ? "'$ary->[$idx]'" : "undef"), | |
1429 | "\n"; | |
1430 | } | |
1431 | } | |
1432 | } | |
1433 | ||
1434 | =begin original | |
1435 | ||
1436 | would print out: | |
1437 | ||
1438 | =end original | |
1439 | ||
1440 | とすると、以下のものが表示されます: | |
1441 | ||
1442 | $-{A}[0] : '1' | |
1443 | $-{A}[1] : '3' | |
1444 | $-{B}[0] : '2' | |
1445 | $-{B}[1] : '4' | |
1446 | ||
1447 | =begin original | |
1448 | ||
1449 | The keys of the C<%-> hash correspond to all buffer names found in | |
1450 | the regular expression. | |
1451 | ||
1452 | =end original | |
1453 | ||
1454 | C<%-> ハッシュのキーは正規表現で見つかった全てのバッファ名に対応します。 | |
1455 | ||
1456 | =begin original | |
1457 | ||
1458 | The behaviour of C<%-> is implemented via the | |
1459 | L<Tie::Hash::NamedCapture> module. | |
1460 | ||
1461 | =end original | |
1462 | ||
1463 | C<%-> の振る舞いは L<Tie::Hash::NamedCapture> モジュールを使って | |
1464 | 実装されています。 | |
1465 | ||
1466 | =begin original | |
1467 | ||
1468 | B<Note:> C<%-> and C<%+> are tied views into a common internal hash | |
1469 | associated with the last successful regular expression. Therefore mixing | |
1470 | iterative access to them via C<each> may have unpredictable results. | |
1471 | Likewise, if the last successful match changes, then the results may be | |
1472 | surprising. | |
1473 | ||
1474 | =end original | |
1475 | ||
1476 | B<注意:> C<%-> and C<%+> は最後に成功した正規表現と関連付けられた共通の | |
1477 | 内部ハッシュと tie されたビューです。 | |
1478 | 従って、C<each> 経由で混ざった反復アクセスを行うと、予測不能の結果と | |
1479 | なります。 | |
1480 | 同様に、最後に成功したマッチングを変更すると、結果は驚くべきものとなります。 | |
1481 | ||
1482 | =item HANDLE->format_name(EXPR) | |
1483 | ||
1484 | 1010 | =item $FORMAT_NAME |
1485 | 1011 | |
1486 | 1012 | =item $~ |
1487 | X<$~> X<$FORMAT_NAME> | |
1488 | 1013 | |
1489 | 1014 | =begin original |
1490 | 1015 | |
1491 | 1016 | The name of the current report format for the currently selected output |
1492 | 1017 | channel. Default is the name of the filehandle. (Mnemonic: brother to |
1493 | 1018 | C<$^>.) |
1494 | 1019 | |
1495 | 1020 | =end original |
1496 | 1021 | |
1497 | 1022 | その時点で選択されている出力チャネルの、その時点でのフォーマット名。 |
1498 | 1023 | デフォルトでは、ファイルハンドルと同名です。 |
1499 | 1024 | (記憶法: C<$^> の兄弟。) |
1500 | 1025 | |
1501 | =item | |
1026 | =item format_top_name HANDLE EXPR | |
1502 | 1027 | |
1503 | 1028 | =item $FORMAT_TOP_NAME |
1504 | 1029 | |
1505 | 1030 | =item $^ |
1506 | X<$^> X<$FORMAT_TOP_NAME> | |
1507 | 1031 | |
1508 | 1032 | =begin original |
1509 | 1033 | |
1510 | 1034 | The name of the current top-of-page format for the currently selected |
1511 | 1035 | output channel. Default is the name of the filehandle with _TOP |
1512 | 1036 | appended. (Mnemonic: points to top of page.) |
1513 | 1037 | |
1514 | 1038 | =end original |
1515 | 1039 | |
1516 | 1040 | その時点で選択されている出力チャネルの、その時点での |
1517 | 1041 | ページ先頭フォーマット名。 |
1518 | 1042 | デフォルトでは、ファイルハンドル名に _TOP を続けたもの。 |
1519 | 1043 | (記憶法: ページの先頭へのポインタ。) |
1520 | 1044 | |
1521 | =item | |
1045 | =item format_line_break_characters HANDLE EXPR | |
1522 | 1046 | |
1523 | 1047 | =item $FORMAT_LINE_BREAK_CHARACTERS |
1524 | 1048 | |
1525 | 1049 | =item $: |
1526 | X<$:> X<FORMAT_LINE_BREAK_CHARACTERS> | |
1527 | 1050 | |
1528 | 1051 | =begin original |
1529 | 1052 | |
1530 | 1053 | The current set of characters after which a string may be broken to |
1531 | 1054 | fill continuation fields (starting with ^) in a format. Default is |
1532 | 1055 | S<" \n-">, to break on whitespace or hyphens. (Mnemonic: a "colon" in |
1533 | 1056 | poetry is a part of a line.) |
1534 | 1057 | |
1535 | 1058 | =end original |
1536 | 1059 | |
1537 | 1060 | フォーマットの充填継続フィールド (^ で始まるもの) への |
1538 | 1061 | 文字列で行分割を許す文字集合。 |
1539 | 1062 | デフォルトは S<" \n-"> で空白か改行の後で行分割が可能となっています。 |
1540 | 1063 | (記憶法: 詩では「コロン」は、行の一部。) |
1541 | 1064 | |
1542 | =item | |
1065 | =item format_formfeed HANDLE EXPR | |
1543 | 1066 | |
1544 | 1067 | =item $FORMAT_FORMFEED |
1545 | 1068 | |
1546 | 1069 | =item $^L |
1547 | X<$^L> X<$FORMAT_FORMFEED> | |
1548 | 1070 | |
1549 | 1071 | =begin original |
1550 | 1072 | |
1551 | 1073 | What formats output as a form feed. Default is \f. |
1552 | 1074 | |
1553 | 1075 | =end original |
1554 | 1076 | |
1555 | 1077 | フォーマット出力で、改ページのために出力されるもの。 |
1556 | 1078 | デフォルトは \f。 |
1557 | 1079 | |
1558 | 1080 | =item $ACCUMULATOR |
1559 | 1081 | |
1560 | 1082 | =item $^A |
1561 | X<$^A> X<$ACCUMULATOR> | |
1562 | 1083 | |
1563 | 1084 | =begin original |
1564 | 1085 | |
1565 | 1086 | The current value of the write() accumulator for format() lines. A format |
1566 | 1087 | contains formline() calls that put their result into C<$^A>. After |
1567 | 1088 | calling its format, write() prints out the contents of C<$^A> and empties. |
1568 | 1089 | So you never really see the contents of C<$^A> unless you call |
1569 | 1090 | formline() yourself and then look at it. See L<perlform> and |
1570 | 1091 | L<perlfunc/formline()>. |
1571 | 1092 | |
1572 | 1093 | =end original |
1573 | 1094 | |
1574 | 1095 | format() 行のための、その時点での write() アキュムレータの値。 |
1575 | 1096 | format には、C<$^A> に結果を残す、formline() 呼び出しが含まれます。 |
1576 | 1097 | 自分のフォーマットを呼び出した後で、 |
1577 | 1098 | write() は C<$^A> の内容を出力してから消去します。 |
1578 | 1099 | したがって、自分で formline() を呼び出すのでなければ、 |
1579 | 1100 | C<$^A> の値が見えることはありません。 |
1580 | 1101 | L<perlform> と L<perlfunc/formline()> を参照してください。 |
1581 | 1102 | |
1582 | 1103 | =item $CHILD_ERROR |
1583 | 1104 | |
1584 | 1105 | =item $? |
1585 | X<$?> X<$CHILD_ERROR> | |
1586 | 1106 | |
1587 | 1107 | =begin original |
1588 | 1108 | |
1589 | 1109 | The status returned by the last pipe close, backtick (C<``>) command, |
1590 | 1110 | successful call to wait() or waitpid(), or from the system() |
1591 | 1111 | operator. This is just the 16-bit status word returned by the |
1592 | ||
1112 | wait() system call (or else is made up to look like it). Thus, the | |
1593 | 1113 | exit value of the subprocess is really (C<<< $? >> 8 >>>), and |
1594 | 1114 | C<$? & 127> gives which signal, if any, the process died from, and |
1595 | 1115 | C<$? & 128> reports whether there was a core dump. (Mnemonic: |
1596 | 1116 | similar to B<sh> and B<ksh>.) |
1597 | 1117 | |
1598 | 1118 | =end original |
1599 | 1119 | |
1600 | 1120 | 最後に close したパイプ、バッククォート (C<``>) コマンド、 |
1601 | 1121 | 成功した wait() または waitpid() 呼び出し、system() 演算子が返したステータス。 |
1602 | このステータスワードは | |
1122 | このステータスワードは wait() システムコールが返した | |
1603 | 1123 | 16 ビットのステータス(またはそのように見えるもの)です。 |
1604 | 1124 | 従ってサブプロセスの exit 値は、実際には (C<<< $? >> 8 >>>) |
1605 | 1125 | で、C<$? & 127> は、もしあれば、そのプロセスを止めたシグナルで、 |
1606 | 1126 | C<$? & 128> はコアダンプがあるかどうかを示します。 |
1607 | 1127 | (記憶法: B<sh> や B<ksh> と同様。) |
1608 | 1128 | |
1609 | 1129 | =begin original |
1610 | 1130 | |
1611 | 1131 | Additionally, if the C<h_errno> variable is supported in C, its value |
1612 | 1132 | is returned via $? if any C<gethost*()> function fails. |
1613 | 1133 | |
1614 | 1134 | =end original |
1615 | 1135 | |
1616 | 1136 | さらに、C で C<h_errno> 変数に対応している場合は、 |
1617 | 1137 | C<gethost*()> が失敗したときに $? を通して返されます。 |
1618 | 1138 | |
1619 | 1139 | =begin original |
1620 | 1140 | |
1621 | 1141 | If you have installed a signal handler for C<SIGCHLD>, the |
1622 | 1142 | value of C<$?> will usually be wrong outside that handler. |
1623 | 1143 | |
1624 | 1144 | =end original |
1625 | 1145 | |
1626 | 1146 | C<SIGCHLD> のシグナルハンドラを設定した場合、 |
1627 | 1147 | C<$?> の値は通常ハンドラの外側では正しくない値となります。 |
1628 | 1148 | |
1629 | 1149 | =begin original |
1630 | 1150 | |
1631 | 1151 | Inside an C<END> subroutine C<$?> contains the value that is going to be |
1632 | 1152 | given to C<exit()>. You can modify C<$?> in an C<END> subroutine to |
1633 | 1153 | change the exit status of your program. For example: |
1634 | 1154 | |
1635 | 1155 | =end original |
1636 | 1156 | |
1637 | 1157 | C<END> サブルーチンの内側では C<$?> には C<exit()> に渡されようとしている |
1638 | 1158 | 値を含みます。 |
1639 | 1159 | プログラムの終了ステータスを変更するために、C<END> サブルーチン 内で |
1640 | 1160 | C<$?> を変更できます。 |
1641 | 1161 | 例えば: |
1642 | 1162 | |
1643 | 1163 | END { |
1644 | 1164 | $? = 1 if $? == 255; # die would make it 255 |
1645 | 1165 | } |
1646 | 1166 | |
1647 | 1167 | =begin original |
1648 | 1168 | |
1649 | 1169 | Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect the |
1650 | 1170 | actual VMS exit status, instead of the default emulation of POSIX |
1651 | status | |
1171 | status. | |
1652 | 1172 | |
1653 | 1173 | =end original |
1654 | 1174 | |
1655 | 1175 | VMS では、C<use vmsish 'status'> を指定すると、 |
1656 | 1176 | C<$?> はPOSIX ステータスをエミュレートしたものではなく、 |
1657 | 実際の VMS 終了ステータスを反映します | |
1177 | 実際の VMS 終了ステータスを反映します。 | |
1658 | 参照してください。 | |
1659 | 1178 | |
1660 | 1179 | =begin original |
1661 | 1180 | |
1662 | 1181 | Also see L<Error Indicators>. |
1663 | 1182 | |
1664 | 1183 | =end original |
1665 | 1184 | |
1666 | 1185 | L<Error Indicators> も参照して下さい。 |
1667 | 1186 | |
1668 | =item ${^CHILD_ERROR_NATIVE} | |
1669 | X<$^CHILD_ERROR_NATIVE> | |
1670 | ||
1671 | =begin original | |
1672 | ||
1673 | The native status returned by the last pipe close, backtick (C<``>) | |
1674 | command, successful call to wait() or waitpid(), or from the system() | |
1675 | operator. On POSIX-like systems this value can be decoded with the | |
1676 | WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG | |
1677 | and WIFCONTINUED functions provided by the L<POSIX> module. | |
1678 | ||
1679 | =end original | |
1680 | ||
1681 | The native status returned by | |
1682 | 最後のパイプクローズ、逆クォート (C<``>) コマンド、wait() と waitpid() の | |
1683 | 成功した呼び出し、system() 演算子から返された、ネイティブなステータスです。 | |
1684 | POSIX 風システムでは、この値は L<POSIX> モジュールで提供される | |
1685 | WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG, | |
1686 | WIFCONTINUED 関数でデコードできます。 | |
1687 | ||
1688 | =begin original | |
1689 | ||
1690 | Under VMS this reflects the actual VMS exit status; i.e. it is the same | |
1691 | as $? when the pragma C<use vmsish 'status'> is in effect. | |
1692 | ||
1693 | =end original | |
1694 | ||
1695 | VMS ではこれは実際の VMS の終了ステータスを反映します; | |
1696 | 言い換えると、これは C<use vmsish 'status'> プラグマが有効なときの $? と | |
1697 | 同じです。 | |
1698 | ||
1699 | =item ${^ENCODING} | |
1700 | X<$^ENCODING> | |
1701 | ||
1702 | =begin original | |
1703 | ||
1704 | The I<object reference> to the Encode object that is used to convert | |
1705 | the source code to Unicode. Thanks to this variable your perl script | |
1706 | does not have to be written in UTF-8. Default is I<undef>. The direct | |
1707 | manipulation of this variable is highly discouraged. | |
1708 | ||
1709 | =end original | |
1710 | ||
1711 | ソースコードを Unicode に変換するために使われる Encode オブジェクトへの | |
1712 | I<オブジェクトリファレンス> 。 | |
1713 | この変数のおかげで、perl スクリプトを UTF-8 で書く必要がありません。 | |
1714 | デフォルトは I<undef> 。 | |
1715 | この変数を直接操作することはとても推奨できません。 | |
1716 | ||
1717 | 1187 | =item $OS_ERROR |
1718 | 1188 | |
1719 | 1189 | =item $ERRNO |
1720 | 1190 | |
1721 | 1191 | =item $! |
1722 | X<$!> X<$ERRNO> X<$OS_ERROR> | |
1723 | 1192 | |
1724 | 1193 | =begin original |
1725 | 1194 | |
1726 | 1195 | If used numerically, yields the current value of the C C<errno> |
1727 | variable, | |
1196 | variable, with all the usual caveats. (This means that you shouldn't | |
1728 | ||
1197 | depend on the value of C<$!> to be anything in particular unless | |
1729 | on | |
1198 | you've gotten a specific error return indicating a system error.) | |
1199 | If used an a string, yields the corresponding system error string. | |
1731 | =end original | |
1732 | ||
1733 | 数値として使われると、その時点の C の C<errno> 変数の値が得られます; | |
1734 | 言い換えると、もしシステムコールやライブラリ呼び出しが失敗すると、 | |
1735 | この変数がセットされます。 | |
1736 | これは、C<$!> の値が意味を持つのは B<失敗> の I<直後> だけということを | |
1737 | 意味します。 | |
1738 | ||
1739 | if (open my $fh, "<", $filename) { | |
1740 | # Here $! is meaningless. | |
1741 | ... | |
1742 | } else { | |
1743 | # ONLY here is $! meaningful. | |
1744 | ... | |
1745 | # Already here $! might be meaningless. | |
1746 | } | |
1747 | # Since here we might have either success or failure, | |
1748 | # here $! is meaningless. | |
1749 | ||
1750 | =begin original | |
1751 | ||
1752 | In the above I<meaningless> stands for anything: zero, non-zero, | |
1753 | C<undef>. A successful system or library call does B<not> set | |
1754 | the variable to zero. | |
1755 | ||
1756 | =end original | |
1757 | ||
1758 | 上記の I<meaningless> は何でもあり得ます: 0、非 0、C<undef>。 | |
1759 | システムコールやライブラリ呼び出しが成功した場合は、この変数は 0 に | |
1760 | セット B<されません>。 | |
1761 | ||
1762 | =begin original | |
1763 | ||
1764 | If used as a string, yields the corresponding system error string. | |
1765 | 1200 | You can assign a number to C<$!> to set I<errno> if, for instance, |
1766 | 1201 | you want C<"$!"> to return the string for error I<n>, or you want |
1767 | 1202 | to set the exit value for the die() operator. (Mnemonic: What just |
1768 | 1203 | went bang?) |
1769 | 1204 | |
1770 | 1205 | =end original |
1771 | 1206 | |
1207 | 数値として使われると、その時点の C の C<errno> 変数の値が | |
1208 | (通常の注意事項と共に) 得られます。 | |
1209 | (これは、システムエラーを示す特定のエラーが得られた場合でもなければ、 | |
1210 | C<$!> の値が、特に何かを示すものであると、頼ってはならないということです。) | |
1772 | 1211 | 文字列として使われると、対応するシステムエラーのメッセージ文字列が得られます。 |
1773 | 1212 | たとえば、C<$!> にエラーの文字列を返して欲しいならば、あるいは、 |
1774 | 1213 | die() 演算子の exit 値を設定するために、I<errno> を設定するため |
1775 | 1214 | C<$!> へ代入を行なうことが可能です。 |
1776 | 1215 | (記憶法: 何が bang(!) したか。) |
1777 | 1216 | |
1778 | 1217 | =begin original |
1779 | 1218 | |
1780 | 1219 | Also see L<Error Indicators>. |
1781 | 1220 | |
1782 | 1221 | =end original |
1783 | 1222 | |
1784 | 1223 | L<Error Indicators> も参照して下さい。 |
1785 | 1224 | |
1786 | =item %OS_ERROR | |
1787 | ||
1788 | =item %ERRNO | |
1789 | ||
1790 | =item %! | |
1791 | X<%!> | |
1792 | ||
1793 | =begin original | |
1794 | ||
1795 | Each element of C<%!> has a true value only if C<$!> is set to that | |
1796 | value. For example, C<$!{ENOENT}> is true if and only if the current | |
1797 | value of C<$!> is C<ENOENT>; that is, if the most recent error was | |
1798 | "No such file or directory" (or its moral equivalent: not all operating | |
1799 | systems give that exact error, and certainly not all languages). | |
1800 | To check if a particular key is meaningful on your system, use | |
1801 | C<exists $!{the_key}>; for a list of legal keys, use C<keys %!>. | |
1802 | See L<Errno> for more information, and also see above for the | |
1803 | validity of C<$!>. | |
1804 | ||
1805 | =end original | |
1806 | ||
1807 | C<%!> の各要素は、C<$!> がその値にセットされている場合にのみ真の値を | |
1808 | 持ちます。 | |
1809 | 例えば、C<$!{ENOENT}> は、現在の C<$!> の値が C<ENOENT> の場合にのみ | |
1810 | 真となります; これは、最近のエラーが | |
1811 | "No such file or directory" (あるいは倫理的に等価なもの: 全ての OS が正確に | |
1812 | 同じエラーを出すわけではないですし、全ての言語で出るわけでもありません) の | |
1813 | 場合です。 | |
1814 | あなたのシステムで特定のキーが意味があるかどうかを調べるには、 | |
1815 | C<exists $!{the_key}> を使ってください; 有効なキーのリストを得るには、 | |
1816 | C<keys %!> としてください。 | |
1817 | さらなる情報と、C<$!> のバラエティに関しては、L<Errno> を参照してください。 | |
1818 | ||
1819 | 1225 | =item $EXTENDED_OS_ERROR |
1820 | 1226 | |
1821 | 1227 | =item $^E |
1822 | X<$^E> X<$EXTENDED_OS_ERROR> | |
1823 | 1228 | |
1824 | 1229 | =begin original |
1825 | 1230 | |
1826 | 1231 | Error information specific to the current operating system. At |
1827 | 1232 | the moment, this differs from C<$!> under only VMS, OS/2, and Win32 |
1828 | 1233 | (and for MacPerl). On all other platforms, C<$^E> is always just |
1829 | 1234 | the same as C<$!>. |
1830 | 1235 | |
1831 | 1236 | =end original |
1832 | 1237 | |
1833 | 1238 | 現在のオペレーティングシステムに特化したエラー情報です。 |
1834 | 1239 | 現在のところ、VMS, OS/2, Win32 (と MacPerl) のみで |
1835 | 1240 | C<$!> と異なる値をもちます。 |
1836 | 1241 | その他のプラットフォームでは、C<$^E> はいつも C<$!> と同じです。 |
1837 | 1242 | |
1838 | 1243 | =begin original |
1839 | 1244 | |
1840 | 1245 | Under VMS, C<$^E> provides the VMS status value from the last |
1841 | 1246 | system error. This is more specific information about the last |
1842 | 1247 | system error than that provided by C<$!>. This is particularly |
1843 | 1248 | important when C<$!> is set to B<EVMSERR>. |
1844 | 1249 | |
1845 | 1250 | =end original |
1846 | 1251 | |
1847 | 1252 | VMS では、C<$^E> は最後のシステムエラーの VMS ステータス値です。 |
1848 | 1253 | これは、最後のシステムエラーについて C<$!> で提供されるものより |
1849 | 1254 | 具体的な情報を示します。 |
1850 | 1255 | これは特に C<$!> が B<EVMSERR> にセットされた場合に重要です。 |
1851 | 1256 | |
1852 | 1257 | =begin original |
1853 | 1258 | |
1854 | 1259 | Under OS/2, C<$^E> is set to the error code of the last call to |
1855 | 1260 | OS/2 API either via CRT, or directly from perl. |
1856 | 1261 | |
1857 | 1262 | =end original |
1858 | 1263 | |
1859 | 1264 | OS/2 では、C<$^E> は CRT 経由、または Perl から直接呼び出された |
1860 | 1265 | 最後の OS/2 API のエラーコードがセットされます。 |
1861 | 1266 | |
1862 | 1267 | =begin original |
1863 | 1268 | |
1864 | 1269 | Under Win32, C<$^E> always returns the last error information |
1865 | 1270 | reported by the Win32 call C<GetLastError()> which describes |
1866 | 1271 | the last error from within the Win32 API. Most Win32-specific |
1867 | 1272 | code will report errors via C<$^E>. ANSI C and Unix-like calls |
1868 | 1273 | set C<errno> and so most portable Perl code will report errors |
1869 | 1274 | via C<$!>. |
1870 | 1275 | |
1871 | 1276 | =end original |
1872 | 1277 | |
1873 | 1278 | Win32 では、C<$^E> は Win32 API での最後のエラーの内容を返す |
1874 | 1279 | C<GetLastError()> Win32 呼び出しで報告される最新のエラー情報を |
1875 | 1280 | 返します。 |
1876 | 1281 | ほとんどの Win32 固有のコードはエラーを C<$^E> 経由で返します。 |
1877 | 1282 | ANSI C と Unix 風の呼び出しは C<errno> をセットするので、 |
1878 | 1283 | ほとんどの移植性のある Perl コードは C<$!> 経由で |
1879 | 1284 | エラーを報告します。 |
1880 | 1285 | |
1881 | 1286 | =begin original |
1882 | 1287 | |
1883 | 1288 | Caveats mentioned in the description of C<$!> generally apply to |
1884 | 1289 | C<$^E>, also. (Mnemonic: Extra error explanation.) |
1885 | 1290 | |
1886 | 1291 | =end original |
1887 | 1292 | |
1888 | 1293 | C<$!> の説明で触れた問題点は一般的に C<$^E> にも適用されます。 |
1889 | 1294 | (記憶法: 追加の(Extra)エラーの説明。) |
1890 | 1295 | |
1891 | 1296 | =begin original |
1892 | 1297 | |
1893 | 1298 | Also see L<Error Indicators>. |
1894 | 1299 | |
1895 | 1300 | =end original |
1896 | 1301 | |
1897 | 1302 | L<Error Indicators> も参照して下さい。 |
1898 | 1303 | |
1899 | 1304 | =item $EVAL_ERROR |
1900 | 1305 | |
1901 | 1306 | =item $@ |
1902 | X<$@> X<$EVAL_ERROR> | |
1903 | 1307 | |
1904 | 1308 | =begin original |
1905 | 1309 | |
1906 | The Perl syntax error message from the last eval() operator. | |
1310 | The Perl syntax error message from the last eval() operator. If null, the | |
1907 | ||
1311 | last eval() parsed and executed correctly (although the operations you | |
1908 | ||
1312 | invoked may have failed in the normal fashion). (Mnemonic: Where was | |
1909 | ||
1313 | the syntax error "at"?) | |
1910 | 1314 | |
1911 | 1315 | =end original |
1912 | 1316 | |
1913 | 1317 | 最後の eval() 操作子による Perl の構文エラーメッセージです。 |
1914 | ||
1318 | 空文字列であれば、最後の eval() が正常に | |
1915 | 1319 | 解析され、実行されたことになります (が、実行した演算子が、 |
1916 | 1320 | 通常の意味で失敗しているかもしれません)。 |
1917 | 1321 | (記憶法: どこで ("at" where) 構文エラーが起ったか。) |
1918 | 1322 | |
1919 | 1323 | =begin original |
1920 | 1324 | |
1921 | 1325 | Warning messages are not collected in this variable. You can, |
1922 | 1326 | however, set up a routine to process warnings by setting C<$SIG{__WARN__}> |
1923 | 1327 | as described below. |
1924 | 1328 | |
1925 | 1329 | =end original |
1926 | 1330 | |
1927 | 1331 | 警告メッセージはこの変数に入りません。 |
1928 | 1332 | しかし、後述する C<$SIG{__WARN__}> にセットすることで |
1929 | 1333 | 警告を処理するルーチンを設定できます。 |
1930 | 1334 | |
1931 | 1335 | =begin original |
1932 | 1336 | |
1933 | 1337 | Also see L<Error Indicators>. |
1934 | 1338 | |
1935 | 1339 | =end original |
1936 | 1340 | |
1937 | 1341 | L<Error Indicators> も参照して下さい。 |
1938 | 1342 | |
1939 | 1343 | =item $PROCESS_ID |
1940 | 1344 | |
1941 | 1345 | =item $PID |
1942 | 1346 | |
1943 | 1347 | =item $$ |
1944 | X<$$> X<$PID> X<$PROCESS_ID> | |
1945 | 1348 | |
1946 | 1349 | =begin original |
1947 | 1350 | |
1948 | 1351 | The process number of the Perl running this script. You should |
1949 | 1352 | consider this variable read-only, although it will be altered |
1950 | 1353 | across fork() calls. (Mnemonic: same as shells.) |
1951 | 1354 | |
1952 | 1355 | =end original |
1953 | 1356 | |
1954 | 1357 | スクリプトを実行している Perl のプロセス番号です。 |
1955 | 1358 | この変数は read-only と考えるべきですが、 |
1956 | 1359 | fork() 呼び出しによって値は変わります。 |
1957 | 1360 | (記憶法: シェルと同じ。) |
1958 | 1361 | |
1959 | =begin original | |
1960 | ||
1961 | Note for Linux users: on Linux, the C functions C<getpid()> and | |
1962 | C<getppid()> return different values from different threads. In order to | |
1963 | be portable, this behavior is not reflected by C<$$>, whose value remains | |
1964 | consistent across threads. If you want to call the underlying C<getpid()>, | |
1965 | you may use the CPAN module C<Linux::Pid>. | |
1966 | ||
1967 | =end original | |
1968 | ||
1969 | Linux ユーザーへの注意: Linux では、C 関数 C<getpid()> と C<getppid()> は | |
1970 | スレッドが異なると異なった値を返します。 | |
1971 | 移植性のために、この振る舞いは C<$$> には反映されず、この値はスレッド間で | |
1972 | 一貫しています。 | |
1973 | もし内在する C<getpid()> を呼び出したい場合は、CPAN モジュール | |
1974 | C<Linux::Pid> が使えます。 | |
1975 | ||
1976 | 1362 | =item $REAL_USER_ID |
1977 | 1363 | |
1978 | 1364 | =item $UID |
1979 | 1365 | |
1980 | 1366 | =item $< |
1981 | X<< $< >> X<$UID> X<$REAL_USER_ID> | |
1982 | 1367 | |
1983 | 1368 | =begin original |
1984 | 1369 | |
1985 | 1370 | The real uid of this process. (Mnemonic: it's the uid you came I<from>, |
1986 | if you're running setuid.) | |
1371 | if you're running setuid.) | |
1987 | the effective uid at the same time by using POSIX::setuid(). Since | |
1988 | changes to $< require a system call, check $! after a change attempt to | |
1989 | detect any possible errors. | |
1990 | 1372 | |
1991 | 1373 | =end original |
1992 | 1374 | |
1993 | 1375 | 本プロセスの実 uid を示します。 |
1994 | 1376 | (記憶法: setuid で実行中であれば、そこ「から」来た uid です。) |
1995 | POSIX::setuid() を使って、実効 UID と実 UID を同時に変更できます。 | |
1996 | $> を変更にはシステムコールが必要なので、起こりうるエラーを検出するために | |
1997 | $! のチェックが必要です。 | |
1998 | 1377 | |
1999 | 1378 | =item $EFFECTIVE_USER_ID |
2000 | 1379 | |
2001 | 1380 | =item $EUID |
2002 | 1381 | |
2003 | 1382 | =item $> |
2004 | X<< $> >> X<$EUID> X<$EFFECTIVE_USER_ID> | |
2005 | 1383 | |
2006 | 1384 | =begin original |
2007 | 1385 | |
2008 | 1386 | The effective uid of this process. Example: |
2009 | 1387 | |
2010 | 1388 | =end original |
2011 | 1389 | |
2012 | 1390 | 本プロセスの実効 uid を示します。 |
2013 | 1391 | 例: |
2014 | 1392 | |
2015 | 1393 | $< = $>; # set real to effective uid |
2016 | 1394 | ($<,$>) = ($>,$<); # swap real and effective uid |
2017 | 1395 | |
2018 | 1396 | =begin original |
2019 | 1397 | |
2020 | You can change both the effective uid and the real uid at the same | |
2021 | time by using POSIX::setuid(). Changes to $> require a check to $! | |
2022 | to detect any possible errors after an attempted change. | |
2023 | ||
2024 | =end original | |
2025 | ||
2026 | POSIX::setuid() を使って、実効 UID と実 UID を同時に変更できます。 | |
2027 | $> を変更した場合は、変更時に起こりうるエラーを検出するために $! の | |
2028 | チェックが必要です。 | |
2029 | ||
2030 | =begin original | |
2031 | ||
2032 | 1398 | (Mnemonic: it's the uid you went I<to>, if you're running setuid.) |
2033 | 1399 | C<< $< >> and C<< $> >> can be swapped only on machines |
2034 | 1400 | supporting setreuid(). |
2035 | 1401 | |
2036 | 1402 | =end original |
2037 | 1403 | |
2038 | 1404 | (記憶法: setuid で実行中であれば、そこ「へ」行く uidです。) |
2039 | 1405 | C<< $< >> と C<< $> >> の交換は、setreuid() をサポートしている |
2040 | 1406 | マシンでのみ可能です。 |
2041 | 1407 | |
2042 | 1408 | =item $REAL_GROUP_ID |
2043 | 1409 | |
2044 | 1410 | =item $GID |
2045 | 1411 | |
2046 | 1412 | =item $( |
2047 | X<$(> X<$GID> X<$REAL_GROUP_ID> | |
2048 | 1413 | |
2049 | 1414 | =begin original |
2050 | 1415 | |
2051 | 1416 | The real gid of this process. If you are on a machine that supports |
2052 | 1417 | membership in multiple groups simultaneously, gives a space separated |
2053 | 1418 | list of groups you are in. The first number is the one returned by |
2054 | 1419 | getgid(), and the subsequent ones by getgroups(), one of which may be |
2055 | 1420 | the same as the first number. |
2056 | 1421 | |
2057 | 1422 | =end original |
2058 | 1423 | |
2059 | 本プロセスの実 gid を示します。 | |
1424 | 本プロセスの実 gid を示します。 同時に複数のグループに | |
2060 | ||
1425 | 所属できるマシンでは、所属するグループをスペースで | |
2061 | 1426 | 区切ったリストが得られます。 |
2062 | 1427 | 最初の数値は、getgid() で返されるものです。 |
2063 | 1428 | その後に getgroups() が返す値が続き、その中の 1 つは、 |
2064 | 1429 | 最初の値と同じかもしれません。 |
2065 | 1430 | |
2066 | 1431 | =begin original |
2067 | 1432 | |
2068 | 1433 | However, a value assigned to C<$(> must be a single number used to |
2069 | 1434 | set the real gid. So the value given by C<$(> should I<not> be assigned |
2070 | back to C<$(> without being forced numeric, such as by adding zero. | |
1435 | back to C<$(> without being forced numeric, such as by adding zero. | |
2071 | that this is different to the effective gid (C<$)>) which does take a | |
2072 | list. | |
2073 | 1436 | |
2074 | 1437 | =end original |
2075 | 1438 | |
2076 | 1439 | しかし、C<$(> に代入された値は実際の gid に設定された値の |
2077 | 1440 | 一つでなければなりません。 |
2078 | 1441 | 従って、 C<$(> で与えられた値はゼロを足すことによって |
2079 | 1442 | 数値化することなく C<$(> に書き戻すべきではありません。 |
2080 | これはリストが得られる実行 GID (C<$)>) とは違うことに注意してください。 | |
2081 | 1443 | |
2082 | 1444 | =begin original |
2083 | 1445 | |
2084 | You can change both the real gid and the effective gid at the same | |
2085 | time by using POSIX::setgid(). Changes to $( require a check to $! | |
2086 | to detect any possible errors after an attempted change. | |
2087 | ||
2088 | =end original | |
2089 | ||
2090 | POSIX::setgid() を使って、実 GID と実効 GID の両方を同時に変更できます。 | |
2091 | $( を変更した場合は、変更しようとしたときに起こりうるエラーを検出するために | |
2092 | $! をチェックする必要があります。 | |
2093 | ||
2094 | =begin original | |
2095 | ||
2096 | 1446 | (Mnemonic: parentheses are used to I<group> things. The real gid is the |
2097 | 1447 | group you I<left>, if you're running setgid.) |
2098 | 1448 | |
2099 | 1449 | =end original |
2100 | 1450 | |
2101 | 1451 | (記憶法: 括弧は、I<グループ化>に使われます。 |
2102 | 1452 | setgid で実行中であれば、実 gid は I<left> した、 |
2103 | 1453 | つまり離れたグループです。) |
2104 | 1454 | |
2105 | 1455 | =item $EFFECTIVE_GROUP_ID |
2106 | 1456 | |
2107 | 1457 | =item $EGID |
2108 | 1458 | |
2109 | 1459 | =item $) |
2110 | X<$)> X<$EGID> X<$EFFECTIVE_GROUP_ID> | |
2111 | 1460 | |
2112 | 1461 | =begin original |
2113 | 1462 | |
2114 | 1463 | The effective gid of this process. If you are on a machine that |
2115 | 1464 | supports membership in multiple groups simultaneously, gives a space |
2116 | 1465 | separated list of groups you are in. The first number is the one |
2117 | 1466 | returned by getegid(), and the subsequent ones by getgroups(), one of |
2118 | 1467 | which may be the same as the first number. |
2119 | 1468 | |
2120 | 1469 | =end original |
2121 | 1470 | |
2122 | 1471 | 本プロセスの実効 gid を示します。 |
2123 | 1472 | 同時に複数のグループに所属できるマシンでは、 |
2124 | 1473 | 所属するグループをスペースで区切ったリストが得られます。 |
2125 | 1474 | 最初の数値は、getegid() で返されるものです。 |
2126 | 1475 | その後に getgroups()が返す値が続き、その中の 1 つは、 |
2127 | 1476 | 最初の値と同じかもしれません。 |
2128 | 1477 | |
2129 | 1478 | =begin original |
2130 | 1479 | |
2131 | 1480 | Similarly, a value assigned to C<$)> must also be a space-separated |
2132 | 1481 | list of numbers. The first number sets the effective gid, and |
2133 | 1482 | the rest (if any) are passed to setgroups(). To get the effect of an |
2134 | 1483 | empty list for setgroups(), just repeat the new effective gid; that is, |
2135 | 1484 | to force an effective gid of 5 and an effectively empty setgroups() |
2136 | 1485 | list, say C< $) = "5 5" >. |
2137 | 1486 | |
2138 | 1487 | =end original |
2139 | 1488 | |
2140 | 1489 | 同様に、C<$)> へ代入する値はスペースで区切られた数値の |
2141 | 1490 | リストでなければなりません。 |
2142 | 1491 | 最初の数値は実効 gid を設定し、残りの数値は(もしあれば) setgroups() に |
2143 | 1492 | 渡されます。 |
2144 | 1493 | setgroups() に空リストを渡したい場合は、単に新しい実効 gid を |
2145 | 1494 | 繰り返してください。 |
2146 | 1495 | つまり、実効 gid を 5 にして、setgroups() に空リストを渡したい場合は、 |
2147 | 1496 | C< $) = "5 5" > としてください。 |
2148 | 1497 | |
2149 | 1498 | =begin original |
2150 | 1499 | |
2151 | You can change both the effective gid and the real gid at the same | |
2152 | time by using POSIX::setgid() (use only a single numeric argument). | |
2153 | Changes to $) require a check to $! to detect any possible errors | |
2154 | after an attempted change. | |
2155 | ||
2156 | =end original | |
2157 | ||
2158 | POSIX::setgid() を使って、実効 GID と実 GID を同時に変更できます。 | |
2159 | (1 つの数値引数だけが使えます)。 | |
2160 | $) を変更した場合は、変更時に起こりうるエラーを検出するために $! の | |
2161 | チェックが必要です。 | |
2162 | ||
2163 | =begin original | |
2164 | ||
2165 | 1500 | (Mnemonic: parentheses are used to I<group> things. The effective gid |
2166 | 1501 | is the group that's I<right> for you, if you're running setgid.) |
2167 | 1502 | |
2168 | 1503 | =end original |
2169 | 1504 | |
2170 | 1505 | (記憶法: 括弧は、I<グループ化>に使われます。 |
2171 | 1506 | setgid で実行中であれば、実効 gid は right な、つまり正しいグループです。) |
2172 | 1507 | |
2173 | 1508 | =begin original |
2174 | 1509 | |
2175 | 1510 | C<< $< >>, C<< $> >>, C<$(> and C<$)> can be set only on |
2176 | 1511 | machines that support the corresponding I<set[re][ug]id()> routine. C<$(> |
2177 | 1512 | and C<$)> can be swapped only on machines supporting setregid(). |
2178 | 1513 | |
2179 | 1514 | =end original |
2180 | 1515 | |
2181 | 1516 | C<< $< >>, C<< $> >>, C<$(>, C<$)> は、実行するマシンで、 |
2182 | 1517 | 対応する I<set[re][ug]id()> ルーティンがサポートされているときにのみ |
2183 | 1518 | 設定可能です。 |
2184 | 1519 | C<$(> と C<$)> の交換は、 |
2185 | 1520 | setregid() がサポートされているマシンでのみ可能です。 |
2186 | 1521 | |
2187 | 1522 | =item $PROGRAM_NAME |
2188 | 1523 | |
2189 | 1524 | =item $0 |
2190 | X<$0> X<$PROGRAM_NAME> | |
2191 | 1525 | |
2192 | 1526 | =begin original |
2193 | 1527 | |
2194 | Contains the name of the program being executed. | |
1528 | Contains the name of the program being executed. On some operating | |
1529 | systems assigning to C<$0> modifies the argument area that the B<ps> | |
1530 | program sees. This is more useful as a way of indicating the current | |
1531 | program state than it is for hiding the program you're running. | |
1532 | (Mnemonic: same as B<sh> and B<ksh>.) | |
2195 | 1533 | |
2196 | 1534 | =end original |
2197 | 1535 | |
2198 | 1536 | 実行されているプログラムの名前を示します。 |
2199 | ||
2200 | =begin original | |
2201 | ||
2202 | On some (read: not all) operating systems assigning to C<$0> modifies | |
2203 | the argument area that the C<ps> program sees. On some platforms you | |
2204 | may have to use special C<ps> options or a different C<ps> to see the | |
2205 | changes. Modifying the $0 is more useful as a way of indicating the | |
2206 | current program state than it is for hiding the program you're | |
2207 | running. (Mnemonic: same as B<sh> and B<ksh>.) | |
2208 | ||
2209 | =end original | |
2210 | ||
2211 | 1537 | C<$0> に代入を行なうことで B<ps>) プログラムが覗く、 |
2212 | 引数エリアを修正できるシステムもあります | |
1538 | 引数エリアを修正できるシステムもあります。 | |
2213 | ||
1539 | 実行しているプログラムを隠すよりは、 | |
2214 | 1540 | 実行中のプログラムの状態を表示するときに、使うとよいでしょう。 |
2215 | 1541 | (記憶法: B<sh> や B<ksh> と同じ。) |
2216 | 1542 | |
2217 | 1543 | =begin original |
2218 | 1544 | |
2219 | Note that there are platform specific limitations on the maximum | |
2220 | length of C<$0>. In the most extreme case it may be limited to the | |
2221 | space occupied by the original C<$0>. | |
2222 | ||
2223 | =end original | |
2224 | ||
2225 | C<$0> の最大長にはプラットフォーム固有の制限があることに注意してください。 | |
2226 | 最も極端な場合では、元の C<$0> で占められているサイズに制限されます。 | |
2227 | ||
2228 | =begin original | |
2229 | ||
2230 | In some platforms there may be arbitrary amount of padding, for | |
2231 | example space characters, after the modified name as shown by C<ps>. | |
2232 | In some platforms this padding may extend all the way to the original | |
2233 | length of the argument area, no matter what you do (this is the case | |
2234 | for example with Linux 2.2). | |
2235 | ||
2236 | =end original | |
2237 | ||
2238 | プラットフォームによっては、任意の量のパッディングがある場合があります; | |
2239 | 例えば、C<ps> で見られる修正された名前の後の空白文字です。 | |
2240 | プラットフォームによっては、このパッディングは、あなたが何をしたかに | |
2241 | 関わらず、元の引数のエリア全体に拡張されるものもあります | |
2242 | (例えば、これは Linux 2.2 の場合です)。 | |
2243 | ||
2244 | =begin original | |
2245 | ||
2246 | 1545 | Note for BSD users: setting C<$0> does not completely remove "perl" |
2247 | from the ps(1) output. For example, setting C<$0> to C<"foobar"> | |
1546 | from the ps(1) output. For example, setting C<$0> to C<"foobar"> will | |
2248 | result in C<"perl: foobar (perl)"> | |
1547 | result in C<"perl: foobar (perl)">. This is an operating system | |
2249 | ||
1548 | feature. | |
2250 | and version). This is an operating system feature, Perl cannot help it. | |
2251 | 1549 | |
2252 | 1550 | =end original |
2253 | 1551 | |
2254 | 1552 | BSD ユーザーへの注意: C<$0> に値をセットしても、ps(1) の出力から |
2255 | 1553 | 完全に "perl" の文字列は取り除かれません。 |
2256 | 1554 | 例えば、C<$0> に C<"foobar"> と設定すると、C<"perl: foobar (perl)"> という |
2257 | 結果になります | |
1555 | 結果になります。これはオペレーティングシステムの機能です。 | |
2258 | (C<"perl: "> 接頭辞と" (perl)" 接尾辞が表示されるかどうかは 、正確な | |
2259 | BSD の種類とバージョンに依存します)。 | |
2260 | これはオペレーティングシステムの機能で、Perl は何もできません。 | |
2261 | 1556 | |
2262 | =begin original | |
2263 | ||
2264 | In multithreaded scripts Perl coordinates the threads so that any | |
2265 | thread may modify its copy of the C<$0> and the change becomes visible | |
2266 | to ps(1) (assuming the operating system plays along). Note that | |
2267 | the view of C<$0> the other threads have will not change since they | |
2268 | have their own copies of it. | |
2269 | ||
2270 | =end original | |
2271 | ||
2272 | マルチスレッドスクリプトでは、どのスレッドも自身の C<$0> のコピーを | |
2273 | 変更できて、その変更が(OS が対応しているとして) ps(1) で見えるように、 | |
2274 | Perl がスレッドを調整します。 | |
2275 | 他のスレッドが持っている C<$0> の見え方は(各自が自身のコピーを | |
2276 | 持っているので)変わらないことに注意してください。 | |
2277 | ||
2278 | =begin original | |
2279 | ||
2280 | If the program has been given to perl via the switches C<-e> or C<-E>, | |
2281 | C<$0> will contain the string C<"-e">. | |
2282 | ||
2283 | =end original | |
2284 | ||
2285 | プログラムが perl に C<-e> または C<-E> オプション経由で与えられた場合、 | |
2286 | C<$0> には文字列 C<"-e"> を含みます。 | |
2287 | ||
2288 | 1557 | =item $[ |
2289 | X<$[> | |
2290 | 1558 | |
2291 | 1559 | =begin original |
2292 | 1560 | |
2293 | 1561 | The index of the first element in an array, and of the first character |
2294 | 1562 | in a substring. Default is 0, but you could theoretically set it |
2295 | 1563 | to 1 to make Perl behave more like B<awk> (or Fortran) when |
2296 | 1564 | subscripting and when evaluating the index() and substr() functions. |
2297 | 1565 | (Mnemonic: [ begins subscripts.) |
2298 | 1566 | |
2299 | 1567 | =end original |
2300 | 1568 | |
2301 | 1569 | 配列の最初の要素や、文字列の最初の文字のインデックスを |
2302 | 1570 | 示します。 |
2303 | 1571 | デフォルトは 0 ですが、理論的には、index() 関数や |
2304 | 1572 | substr() 関数を評価するときに、Perl の動作をより B<awk> |
2305 | 1573 | (や Fortran) に近づけるため、1 に設定することもできます。 |
2306 | 1574 | (記憶法: [ は添え字付けの始め。) |
2307 | 1575 | |
2308 | 1576 | =begin original |
2309 | 1577 | |
2310 | 1578 | As of release 5 of Perl, assignment to C<$[> is treated as a compiler |
2311 | 1579 | directive, and cannot influence the behavior of any other file. |
2312 | (That's why you can only assign compile-time constants to it.) | |
2313 | 1580 | Its use is highly discouraged. |
2314 | 1581 | |
2315 | 1582 | =end original |
2316 | 1583 | |
2317 | Perl 5 からは C<$[> への代入は、コンパイラ | |
1584 | Perl 5 からは C<$[> への代入は、コンパイラへのディレクティブとして扱われ、 | |
2318 | 1585 | 他のファイルの動作に影響を与えることがなくなりました。 |
2319 | (これが、コンパイル時定数しか代入できない理由です。) | |
2320 | 1586 | この変数はできるだけ使わないようにしてください。 |
2321 | 1587 | |
2322 | =begin original | |
2323 | ||
2324 | Note that, unlike other compile-time directives (such as L<strict>), | |
2325 | assignment to C<$[> can be seen from outer lexical scopes in the same file. | |
2326 | However, you can use local() on it to strictly bind its value to a | |
2327 | lexical block. | |
2328 | ||
2329 | =end original | |
2330 | ||
2331 | (L<strict> のような) その他のコンパイル時指示子と違って、C<$[> への代入は、 | |
2332 | 同じファイルのより外側のレキシカルスコープからも見えることに注意してください。 | |
2333 | 但し、これに local() を使うことでこの値をレキシカルブロック内に束縛できます。 | |
2334 | ||
2335 | 1588 | =item $] |
2336 | X<$]> | |
2337 | 1589 | |
2338 | 1590 | =begin original |
2339 | 1591 | |
2340 | 1592 | The version + patchlevel / 1000 of the Perl interpreter. This variable |
2341 | 1593 | can be used to determine whether the Perl interpreter executing a |
2342 | 1594 | script is in the right range of versions. (Mnemonic: Is this version |
2343 | 1595 | of perl in the right bracket?) Example: |
2344 | 1596 | |
2345 | 1597 | =end original |
2346 | 1598 | |
2347 | 1599 | Perl インタプリタの version + patchlevel / 1000 が返されます。 |
2348 | 1600 | スクリプトの最初で、そのスクリプトを実行しているインタプリタのバージョンが |
2349 | 1601 | 適切な範囲内にあるかを調べる、といったことができます。 |
2350 | (記憶法: Perl のバージョンは、正しい範囲 (right | |
1602 | (記憶法: Perl のバージョンは、正しい範囲 (right | |
2351 | 例: | |
1603 | bracket) にあるか。) 例: | |
2352 | 1604 | |
2353 | 1605 | warn "No checksumming!\n" if $] < 3.019; |
2354 | 1606 | |
2355 | 1607 | =begin original |
2356 | 1608 | |
2357 | 1609 | See also the documentation of C<use VERSION> and C<require VERSION> |
2358 | 1610 | for a convenient way to fail if the running Perl interpreter is too old. |
2359 | 1611 | |
2360 | 1612 | =end original |
2361 | 1613 | |
2362 | 1614 | 実行する Perl インタプリタが古すぎる場合に終了する便利な方法に |
2363 | 1615 | ついては C<use VERSION> と C<require VERSION> のドキュメントも |
2364 | 1616 | 参照して下さい。 |
2365 | 1617 | |
2366 | 1618 | =begin original |
2367 | 1619 | |
2368 | The floating point representation | |
1620 | The use of this variable is deprecated. The floating point representation | |
2369 | numeric comparisons. See C<$^V> for a | |
1621 | can sometimes lead to inaccurate numeric comparisons. See C<$^V> for a | |
2370 | the Perl version that allows accurate string | |
1622 | more modern representation of the Perl version that allows accurate string | |
1623 | comparisons. | |
2371 | 1624 | |
2372 | 1625 | =end original |
2373 | 1626 | |
2374 | ||
1627 | この変数は使わないようにしてください。 | |
1628 | 浮動小数点表現は数値比較が不正確に成ることがあります。 | |
2375 | 1629 | 文字列比較が使える新しい Perl バージョンの表現方法である C<$^V> を |
2376 | 1630 | 参照して下さい。 |
2377 | 1631 | |
2378 | 1632 | =item $COMPILING |
2379 | 1633 | |
2380 | 1634 | =item $^C |
2381 | X<$^C> X<$COMPILING> | |
2382 | 1635 | |
2383 | 1636 | =begin original |
2384 | 1637 | |
2385 | 1638 | The current value of the flag associated with the B<-c> switch. |
2386 | 1639 | Mainly of use with B<-MO=...> to allow code to alter its behavior |
2387 | 1640 | when being compiled, such as for example to AUTOLOAD at compile |
2388 | time rather than normal, deferred loading. Setting | |
1641 | time rather than normal, deferred loading. See L<perlcc>. Setting | |
2389 | 1642 | C<$^C = 1> is similar to calling C<B::minus_c>. |
2390 | 1643 | |
2391 | 1644 | =end original |
2392 | 1645 | |
2393 | 1646 | B<-c> スイッチに関連付けられた現在の値です。 |
2394 | 1647 | 主に B<-MO=...> と共に用いられ、例えば AUTOLOAD を通常の遅延ロードでは |
2395 | 1648 | なくコンパイル時に実行するといった、コンパイル時の振る舞いを |
2396 | 変えるために用います。 | |
1649 | 変えるために用います。L<perlcc> を参照して下さい。 | |
2397 | 1650 | C<$^C = 1> に設定することは C<B::minus_c> を呼び出すのと似ています。 |
2398 | 1651 | |
2399 | 1652 | =item $DEBUGGING |
2400 | 1653 | |
2401 | 1654 | =item $^D |
2402 | X<$^D> X<$DEBUGGING> | |
2403 | 1655 | |
2404 | 1656 | =begin original |
2405 | 1657 | |
2406 | 1658 | The current value of the debugging flags. (Mnemonic: value of B<-D> |
2407 | switch.) | |
1659 | switch.) | |
2408 | numeric or symbolic values, eg C<$^D = 10> or C<$^D = "st">. | |
2409 | 1660 | |
2410 | 1661 | =end original |
2411 | 1662 | |
2412 | 1663 | デバッグフラグの現在の値を示します。 |
2413 | 1664 | (記憶法: B<-D> スイッチの値。) |
2414 | 読み書き可能です。 | |
2415 | コマンドラインによる等価な機能と同様に、数値とシンボル値が使えます | |
2416 | (例: C<$^D = 10> または C<$^D = "st">)。 | |
2417 | 1665 | |
2418 | =item ${^RE_DEBUG_FLAGS} | |
2419 | ||
2420 | =begin original | |
2421 | ||
2422 | The current value of the regex debugging flags. Set to 0 for no debug output | |
2423 | even when the re 'debug' module is loaded. See L<re> for details. | |
2424 | ||
2425 | =end original | |
2426 | ||
2427 | 正規表現デバッグフラグの現在の値です。 | |
2428 | 0 をセットすると、re 'debug' モジュールが読み込まれていても | |
2429 | デバッグ出力を行いません。 | |
2430 | 詳細については L<re> を参照してください。 | |
2431 | ||
2432 | =item ${^RE_TRIE_MAXBUF} | |
2433 | ||
2434 | =begin original | |
2435 | ||
2436 | Controls how certain regex optimisations are applied and how much memory they | |
2437 | utilize. This value by default is 65536 which corresponds to a 512kB temporary | |
2438 | cache. Set this to a higher value to trade memory for speed when matching | |
2439 | large alternations. Set it to a lower value if you want the optimisations to | |
2440 | be as conservative of memory as possible but still occur, and set it to a | |
2441 | negative value to prevent the optimisation and conserve the most memory. | |
2442 | Under normal situations this variable should be of no interest to you. | |
2443 | ||
2444 | =end original | |
2445 | ||
2446 | どれくらい正規表現の最適化を行い、どれくらいのメモリを利用するかを | |
2447 | 制御します。 | |
2448 | デフォルトではこの値は 65536 で、512kB の一時キャッシュに相当します。 | |
2449 | この値を大きくすると、大きなものとマッチングするときに速度を重視して | |
2450 | 多くのメモリを使います。 | |
2451 | もしできるだけ保守的なメモリ消費をするけれども使うこともある、というように | |
2452 | 最適化したい場合は小さい値を設定します; 負の値を設定すると最適化は行わず、 | |
2453 | 最大限メモリを節約します。 | |
2454 | 通常の状況では、この変数はあなたの興味を引くものではないでしょう。 | |
2455 | ||
2456 | 1666 | =item $SYSTEM_FD_MAX |
2457 | 1667 | |
2458 | 1668 | =item $^F |
2459 | X<$^F> X<$SYSTEM_FD_MAX> | |
2460 | 1669 | |
2461 | 1670 | =begin original |
2462 | 1671 | |
2463 | 1672 | The maximum system file descriptor, ordinarily 2. System file |
2464 | 1673 | descriptors are passed to exec()ed processes, while higher file |
2465 | 1674 | descriptors are not. Also, during an open(), system file descriptors are |
2466 | 1675 | preserved even if the open() fails. (Ordinary file descriptors are |
2467 | 1676 | closed before the open() is attempted.) The close-on-exec |
2468 | 1677 | status of a file descriptor will be decided according to the value of |
2469 | 1678 | C<$^F> when the corresponding file, pipe, or socket was opened, not the |
2470 | 1679 | time of the exec(). |
2471 | 1680 | |
2472 | 1681 | =end original |
2473 | 1682 | |
2474 | システムが使用するファイル記述子の最大値を示し、 | |
1683 | システムが使用するファイル記述子の最大値を示し、 | |
1684 | 通常は 2 です。 | |
2475 | 1685 | システムファイル記述子は、exec() されたプロセスに渡されますが、 |
2476 | 1686 | それ以降のファイル記述子は渡されません。 |
2477 | 1687 | また、open() の実行中は、システムファイル記述子は、 |
2478 | 1688 | たとえ open() が失敗しても、保存されます。 |
2479 | 1689 | (通常のファイル記述子は、open() が実行される前にクローズされます。) |
2480 | 1690 | ファイル記述子の close-on-exec のステータスは、exec() 時ではなく、 |
2481 | 1691 | 対応するファイル、パイプソケットの open 時の C<$^F> の値によって |
2482 | 1692 | 決められます。 |
2483 | 1693 | |
2484 | 1694 | =item $^H |
2485 | 1695 | |
2486 | 1696 | =begin original |
2487 | 1697 | |
2488 | 1698 | WARNING: This variable is strictly for internal use only. Its availability, |
2489 | 1699 | behavior, and contents are subject to change without notice. |
2490 | 1700 | |
2491 | 1701 | =end original |
2492 | 1702 | |
2493 | 1703 | 警告: この変数は厳密に内部使用に限定されます。 |
2494 | 1704 | その可用性、挙動、内容は告知なく変更される可能性があります。 |
2495 | 1705 | |
2496 | 1706 | =begin original |
2497 | 1707 | |
2498 | 1708 | This variable contains compile-time hints for the Perl interpreter. At the |
2499 | 1709 | end of compilation of a BLOCK the value of this variable is restored to the |
2500 | 1710 | value when the interpreter started to compile the BLOCK. |
2501 | 1711 | |
2502 | 1712 | =end original |
2503 | 1713 | |
2504 | 1714 | この変数には Perl インタプリタのコンパイル時のヒントが入ります。 |
2505 | 1715 | BLOCK のコンパイル終了時に、この変数の値は |
2506 | 1716 | インタプリタが BLOCK のコンパイルを開始した時の値に戻されます。 |
2507 | 1717 | |
2508 | 1718 | =begin original |
2509 | 1719 | |
2510 | 1720 | When perl begins to parse any block construct that provides a lexical scope |
2511 | 1721 | (e.g., eval body, required file, subroutine body, loop body, or conditional |
2512 | 1722 | block), the existing value of $^H is saved, but its value is left unchanged. |
2513 | 1723 | When the compilation of the block is completed, it regains the saved value. |
2514 | 1724 | Between the points where its value is saved and restored, code that |
2515 | 1725 | executes within BEGIN blocks is free to change the value of $^H. |
2516 | 1726 | |
2517 | 1727 | =end original |
2518 | 1728 | |
2519 | 1729 | Perl がレキシカルスコープを持つブロック構造(eval の中身、required された |
2520 | 1730 | ファイル、サブルーチンの中身、loop の中身、条件付きブロック)の |
2521 | 1731 | パーズを開始するとき、現在の $^H の値は保存されますが、 |
2522 | 1732 | 値は変更されません。 |
2523 | 1733 | ブロックのコンパイルが終わると、保存された値が戻されます。 |
2524 | 1734 | 値の保存と回復の間の地点で、 |
2525 | 1735 | BEGIN ブロックの中で実行されるコードは自由に |
2526 | 1736 | $^H の値を変更できます。 |
2527 | 1737 | |
2528 | 1738 | =begin original |
2529 | 1739 | |
2530 | 1740 | This behavior provides the semantic of lexical scoping, and is used in, |
2531 | 1741 | for instance, the C<use strict> pragma. |
2532 | 1742 | |
2533 | 1743 | =end original |
2534 | 1744 | |
2535 | 1745 | この振る舞いはレキシカルスコープを持ち、その中で使えます。 |
2536 | 1746 | 例としては C<use strict> があります。 |
2537 | 1747 | |
2538 | 1748 | =begin original |
2539 | 1749 | |
2540 | 1750 | The contents should be an integer; different bits of it are used for |
2541 | 1751 | different pragmatic flags. Here's an example: |
2542 | 1752 | |
2543 | 1753 | =end original |
2544 | 1754 | |
2545 | 1755 | 内容は整数であるべきです。 |
2546 | 1756 | ビット毎に異なるプラグマフラグとして使われます。以下は例です: |
2547 | 1757 | |
2548 | 1758 | sub add_100 { $^H |= 0x100 } |
2549 | 1759 | |
2550 | 1760 | sub foo { |
2551 | 1761 | BEGIN { add_100() } |
2552 | 1762 | bar->baz($boon); |
2553 | 1763 | } |
2554 | 1764 | |
2555 | 1765 | =begin original |
2556 | 1766 | |
2557 | 1767 | Consider what happens during execution of the BEGIN block. At this point |
2558 | 1768 | the BEGIN block has already been compiled, but the body of foo() is still |
2559 | 1769 | being compiled. The new value of $^H will therefore be visible only while |
2560 | 1770 | the body of foo() is being compiled. |
2561 | 1771 | |
2562 | 1772 | =end original |
2563 | 1773 | |
2564 | 1774 | BEGIN ブロックの実行中に起こることを考えてみます。 |
2565 | 1775 | この時点で BEGIN ブロックは既にコンパイルされていますが、 |
2566 | 1776 | foo() の中身はまだコンパイル中です。 |
2567 | 1777 | 従って $^H の新しい値は foo() の中身がコンパイル中にのみ |
2568 | 1778 | 見ることが出来ます。 |
2569 | 1779 | |
2570 | 1780 | =begin original |
2571 | 1781 | |
2572 | 1782 | Substitution of the above BEGIN block with: |
2573 | 1783 | |
2574 | 1784 | =end original |
2575 | 1785 | |
2576 | 1786 | 上記の BEGIN ブロックを以下のように変更すると: |
2577 | 1787 | |
2578 | 1788 | BEGIN { require strict; strict->import('vars') } |
2579 | 1789 | |
2580 | 1790 | =begin original |
2581 | 1791 | |
2582 | 1792 | demonstrates how C<use strict 'vars'> is implemented. Here's a conditional |
2583 | 1793 | version of the same lexical pragma: |
2584 | 1794 | |
2585 | 1795 | =end original |
2586 | 1796 | |
2587 | 1797 | どのように C<use strict 'vars'> が実装されているかがわかります。 |
2588 | 1798 | 以下は同じレキシカルプラグマの条件付き版です: |
2589 | 1799 | |
2590 | 1800 | BEGIN { require strict; strict->import('vars') if $condition } |
2591 | 1801 | |
2592 | 1802 | =item %^H |
2593 | 1803 | |
2594 | 1804 | =begin original |
2595 | 1805 | |
1806 | WARNING: This variable is strictly for internal use only. Its availability, | |
1807 | behavior, and contents are subject to change without notice. | |
1808 | ||
1809 | =end original | |
1810 | ||
1811 | 警告: この変数は厳密に内部使用に限定されます。 | |
1812 | その可用性、挙動、内容は告知なく変更される可能性があります。 | |
1813 | ||
1814 | =begin original | |
1815 | ||
2596 | 1816 | The %^H hash provides the same scoping semantic as $^H. This makes it |
2597 | useful for implementation of lexically scoped pragmas. | |
1817 | useful for implementation of lexically scoped pragmas. | |
2598 | 1818 | |
2599 | 1819 | =end original |
2600 | 1820 | |
2601 | 1821 | %^H ハッシュは $^H と同じスコープを持ちます。 |
2602 | 1822 | これはレキシカルスコープを持つプラグマを実装するのに便利です。 |
2603 | L<perlpragma> を参照してください。 | |
2604 | 1823 | |
2605 | 1824 | =item $INPLACE_EDIT |
2606 | 1825 | |
2607 | 1826 | =item $^I |
2608 | X<$^I> X<$INPLACE_EDIT> | |
2609 | 1827 | |
2610 | 1828 | =begin original |
2611 | 1829 | |
2612 | 1830 | The current value of the inplace-edit extension. Use C<undef> to disable |
2613 | 1831 | inplace editing. (Mnemonic: value of B<-i> switch.) |
2614 | 1832 | |
2615 | 1833 | =end original |
2616 | 1834 | |
2617 | 1835 | 置き換え編集の拡張子の値を示します。 |
2618 | 1836 | 置き換え編集を禁止するためには、C<undef> を設定します。 |
2619 | 1837 | (記憶法: B<-i> スイッチの値。) |
2620 | 1838 | |
2621 | 1839 | =item $^M |
2622 | X<$^M> | |
2623 | 1840 | |
2624 | 1841 | =begin original |
2625 | 1842 | |
2626 | 1843 | By default, running out of memory is an untrappable, fatal error. |
2627 | 1844 | However, if suitably built, Perl can use the contents of C<$^M> |
2628 | 1845 | as an emergency memory pool after die()ing. Suppose that your Perl |
2629 | were compiled with | |
1846 | were compiled with -DPERL_EMERGENCY_SBRK and used Perl's malloc. | |
2630 | 1847 | Then |
2631 | 1848 | |
2632 | 1849 | =end original |
2633 | 1850 | |
2634 | 1851 | デフォルトでは、メモリ不足はトラップできない致命的エラーとなります。 |
2635 | 1852 | しかし、もし適切に構築されていれば、Perl は C<$^M> の中身を |
2636 | 1853 | die() した後の緊急用メモリとして使えます。 |
2637 | Perl が | |
1854 | Perl が -DPERL_EMERGENCY_SBRK 付きでコンパイルされ、 | |
2638 | 1855 | Perl の malloc を使うと仮定します。そして、 |
2639 | 1856 | |
2640 | 1857 | $^M = 'a' x (1 << 16); |
2641 | 1858 | |
2642 | 1859 | =begin original |
2643 | 1860 | |
2644 | 1861 | would allocate a 64K buffer for use in an emergency. See the |
2645 | 1862 | F<INSTALL> file in the Perl distribution for information on how to |
2646 | a | |
1863 | enable this option. To discourage casual use of this advanced | |
2647 | ||
1864 | feature, there is no L<English|English> long name for this variable. | |
2648 | this variable. | |
2649 | 1865 | |
2650 | 1866 | =end original |
2651 | 1867 | |
2652 | 1868 | とすると緊急用の 64K のバッファを割り当てます。 |
2653 | ||
1869 | このオプションを有効にする方法についての情報は | |
2654 | ||
1870 | Perl 配布パッケージに含まれている F<INSTALL> ファイルを参照して下さい。 | |
2655 | F<INSTALL> ファイルを参照して下さい。 | |
2656 | 1871 | この拡張機能を気軽に使えないようにするために、 |
2657 | 1872 | この変数には L<English|English> の長い名前はありません。 |
2658 | 1873 | |
2659 | 1874 | =item $OSNAME |
2660 | 1875 | |
2661 | 1876 | =item $^O |
2662 | X<$^O> X<$OSNAME> | |
2663 | 1877 | |
2664 | 1878 | =begin original |
2665 | 1879 | |
2666 | 1880 | The name of the operating system under which this copy of Perl was |
2667 | 1881 | built, as determined during the configuration process. The value |
2668 | 1882 | is identical to C<$Config{'osname'}>. See also L<Config> and the |
2669 | 1883 | B<-V> command-line switch documented in L<perlrun>. |
2670 | 1884 | |
2671 | 1885 | =end original |
2672 | 1886 | |
2673 | 1887 | この Perl が構築されたオペレーティングシステムの名前です。 |
2674 | 1888 | これは設定プロセス中に決定されます。 |
2675 | 1889 | この値は C<$Config{'osname'}> と同じです。 |
2676 | 1890 | L<Config> と、L<perlrun> でドキュメント化されている |
2677 | 1891 | B<-V> コマンドラインスイッチも参照して下さい。 |
2678 | 1892 | |
2679 | =begin original | |
2680 | ||
2681 | In Windows platforms, $^O is not very helpful: since it is always | |
2682 | C<MSWin32>, it doesn't tell the difference between | |
2683 | 95/98/ME/NT/2000/XP/CE/.NET. Use Win32::GetOSName() or | |
2684 | Win32::GetOSVersion() (see L<Win32> and L<perlport>) to distinguish | |
2685 | between the variants. | |
2686 | ||
2687 | =end original | |
2688 | ||
2689 | Windows プラットフォームでは、$^O はあまり役に立ちません: これは常に | |
2690 | C<MSWin32> となり、95/98/ME/NT/2000/XP/CE/.NET の違いを示していないからです。 | |
2691 | これらを区別するためには、Win32::GetOSName() や Win32::GetOSVersion() を | |
2692 | 使ってください (L<Win32> と L<perlport> を参照してください)。 | |
2693 | ||
2694 | =item ${^OPEN} | |
2695 | ||
2696 | =begin original | |
2697 | ||
2698 | An internal variable used by PerlIO. A string in two parts, separated | |
2699 | by a C<\0> byte, the first part describes the input layers, the second | |
2700 | part describes the output layers. | |
2701 | ||
2702 | =end original | |
2703 | ||
2704 | PerlIO で使われる内部変数です。 | |
2705 | 文字列は C<\0> で分割された二つの部分からなり、前半は入力層を、 | |
2706 | 後半は出力層を示します。 | |
2707 | ||
2708 | 1893 | =item $PERLDB |
2709 | 1894 | |
2710 | 1895 | =item $^P |
2711 | X<$^P> X<$PERLDB> | |
2712 | 1896 | |
2713 | 1897 | =begin original |
2714 | 1898 | |
2715 | 1899 | The internal variable for debugging support. The meanings of the |
2716 | 1900 | various bits are subject to change, but currently indicate: |
2717 | 1901 | |
2718 | 1902 | =end original |
2719 | 1903 | |
2720 | 1904 | デバッグ機能のための内部変数です。 |
2721 | 1905 | それぞれのビットの意味は変わるかもしれませんが、 |
2722 | 1906 | 現在のところは以下の通りです: |
2723 | 1907 | |
2724 | 1908 | =over 6 |
2725 | 1909 | |
2726 | 1910 | =item 0x01 |
2727 | 1911 | |
2728 | 1912 | =begin original |
2729 | 1913 | |
2730 | 1914 | Debug subroutine enter/exit. |
2731 | 1915 | |
2732 | 1916 | =end original |
2733 | 1917 | |
2734 | 1918 | サブルーチンの出入りをデバッグします。 |
2735 | 1919 | |
2736 | 1920 | =item 0x02 |
2737 | 1921 | |
2738 | 1922 | =begin original |
2739 | 1923 | |
2740 | Line-by-line debugging. | |
1924 | Line-by-line debugging. | |
2741 | statement executed. Also causes saving source code lines (like 0x400). | |
2742 | 1925 | |
2743 | 1926 | =end original |
2744 | 1927 | |
2745 | 1928 | 行毎にデバッグします。 |
2746 | 各行を実行する毎に DB::DB() サブルーチンを呼び出します。 | |
2747 | さらに、(0x400 のように) ソースコードを保存します。 | |
2748 | 1929 | |
2749 | 1930 | =item 0x04 |
2750 | 1931 | |
2751 | 1932 | =begin original |
2752 | 1933 | |
2753 | 1934 | Switch off optimizations. |
2754 | 1935 | |
2755 | 1936 | =end original |
2756 | 1937 | |
2757 | 1938 | 最適化を行いません。 |
2758 | 1939 | |
2759 | 1940 | =item 0x08 |
2760 | 1941 | |
2761 | 1942 | =begin original |
2762 | 1943 | |
2763 | 1944 | Preserve more data for future interactive inspections. |
2764 | 1945 | |
2765 | 1946 | =end original |
2766 | 1947 | |
2767 | 1948 | 将来の対話的な検査のためにより多くのデータを保存します。 |
2768 | 1949 | |
2769 | 1950 | =item 0x10 |
2770 | 1951 | |
2771 | 1952 | =begin original |
2772 | 1953 | |
2773 | 1954 | Keep info about source lines on which a subroutine is defined. |
2774 | 1955 | |
2775 | 1956 | =end original |
2776 | 1957 | |
2777 | 1958 | サブルーチンが定義されたソース行に関する情報を保持します。 |
2778 | 1959 | |
2779 | 1960 | =item 0x20 |
2780 | 1961 | |
2781 | 1962 | =begin original |
2782 | 1963 | |
2783 | 1964 | Start with single-step on. |
2784 | 1965 | |
2785 | 1966 | =end original |
2786 | 1967 | |
2787 | 1968 | シングルステップ実行で開始します。 |
2788 | 1969 | |
2789 | 1970 | =item 0x40 |
2790 | 1971 | |
2791 | 1972 | =begin original |
2792 | 1973 | |
2793 | 1974 | Use subroutine address instead of name when reporting. |
2794 | 1975 | |
2795 | 1976 | =end original |
2796 | 1977 | |
2797 | 1978 | 報告時にサブルーチン名でなくサブルーチンのアドレスを使います。 |
2798 | 1979 | |
2799 | 1980 | =item 0x80 |
2800 | 1981 | |
2801 | 1982 | =begin original |
2802 | 1983 | |
2803 | 1984 | Report C<goto &subroutine> as well. |
2804 | 1985 | |
2805 | 1986 | =end original |
2806 | 1987 | |
2807 | 1988 | C<goto &subroutine> も同様に報告します。 |
2808 | 1989 | |
2809 | 1990 | =item 0x100 |
2810 | 1991 | |
2811 | 1992 | =begin original |
2812 | 1993 | |
2813 | 1994 | Provide informative "file" names for evals based on the place they were compiled. |
2814 | 1995 | |
2815 | 1996 | =end original |
2816 | 1997 | |
2817 | 1998 | eval に対して、コンパイルされた位置を元にした「ファイル」名を提供します。 |
2818 | 1999 | |
2819 | 2000 | =item 0x200 |
2820 | 2001 | |
2821 | 2002 | =begin original |
2822 | 2003 | |
2823 | 2004 | Provide informative names to anonymous subroutines based on the place they |
2824 | 2005 | were compiled. |
2825 | 2006 | |
2826 | 2007 | =end original |
2827 | 2008 | |
2828 | 2009 | 無名サブルーチンに対して、 |
2829 | 2010 | コンパイルされた位置を基にした参考名を提供します。 |
2830 | 2011 | |
2831 | =item 0x400 | |
2832 | ||
2833 | =begin original | |
2834 | ||
2835 | Save source code lines into C<@{"_<$filename"}>. | |
2836 | ||
2837 | =end original | |
2838 | ||
2839 | ソースコードの行数を C<@{"_<$filename"}> に保存します。 | |
2840 | ||
2841 | 2012 | =back |
2842 | 2013 | |
2843 | 2014 | =begin original |
2844 | 2015 | |
2845 | 2016 | Some bits may be relevant at compile-time only, some at |
2846 | 2017 | run-time only. This is a new mechanism and the details may change. |
2847 | See also L<perldebguts>. | |
2848 | 2018 | |
2849 | 2019 | =end original |
2850 | 2020 | |
2851 | ||
2021 | コンパイル時にのみ有効なビットもあり、実行時にのみ有効なビットもあります。 | |
2852 | ||
2022 | これは新しいメカニズムであり、詳細は変わるかもしれません。 | |
2853 | See also L<perldebguts>. | |
2854 | 2023 | |
2855 | 2024 | =item $LAST_REGEXP_CODE_RESULT |
2856 | 2025 | |
2857 | 2026 | =item $^R |
2858 | X<$^R> X<$LAST_REGEXP_CODE_RESULT> | |
2859 | 2027 | |
2860 | 2028 | =begin original |
2861 | 2029 | |
2862 | 2030 | The result of evaluation of the last successful C<(?{ code })> |
2863 | 2031 | regular expression assertion (see L<perlre>). May be written to. |
2864 | 2032 | |
2865 | 2033 | =end original |
2866 | 2034 | |
2867 | 2035 | 最後に成功した C<(?{ code })> 正規表現アサートの評価の結果です |
2868 | 2036 | (L<perlre> を参照して下さい)。おそらくもっと書き足します。 |
2869 | 2037 | |
2870 | 2038 | =item $EXCEPTIONS_BEING_CAUGHT |
2871 | 2039 | |
2872 | 2040 | =item $^S |
2873 | X<$^S> X<$EXCEPTIONS_BEING_CAUGHT> | |
2874 | 2041 | |
2875 | 2042 | =begin original |
2876 | 2043 | |
2877 | Current state of the interpreter. | |
2044 | Current state of the interpreter. Undefined if parsing of the current | |
2045 | module/eval is not finished (may happen in $SIG{__DIE__} and | |
2046 | $SIG{__WARN__} handlers). True if inside an eval(), otherwise false. | |
2878 | 2047 | |
2879 | 2048 | =end original |
2880 | 2049 | |
2881 | 2050 | 現在のインタプリタの状態を示します。 |
2051 | 現在のモジュール/eval のパーズが終了していない場合は | |
2052 | 未定義です(これは $SIG{__DIE__} と $SIG{__WARN__} のハンドラで | |
2053 | 起こり得ます)。 | |
2054 | eval() の内部では真、それ以外では偽となります。 | |
2882 | 2055 | |
2883 | =begin original | |
2884 | ||
2885 | $^S State | |
2886 | --------- ------------------- | |
2887 | undef Parsing module/eval | |
2888 | true (1) Executing an eval | |
2889 | false (0) Otherwise | |
2890 | ||
2891 | =end original | |
2892 | ||
2893 | $^S State | |
2894 | --------- ------------------- | |
2895 | undef モジュール/eval のパース中 | |
2896 | 真 (1) eval の実行中 | |
2897 | 偽 (0) その他 | |
2898 | ||
2899 | =begin original | |
2900 | ||
2901 | The first state may happen in $SIG{__DIE__} and $SIG{__WARN__} handlers. | |
2902 | ||
2903 | =end original | |
2904 | ||
2905 | 最初の状態は $SIG{__DIE__} と $SIG{__WARN__} のハンドラで起きる可能性が | |
2906 | あります。 | |
2907 | ||
2908 | 2056 | =item $BASETIME |
2909 | 2057 | |
2910 | 2058 | =item $^T |
2911 | X<$^T> X<$BASETIME> | |
2912 | 2059 | |
2913 | 2060 | =begin original |
2914 | 2061 | |
2915 | 2062 | The time at which the program began running, in seconds since the |
2916 | 2063 | epoch (beginning of 1970). The values returned by the B<-M>, B<-A>, |
2917 | 2064 | and B<-C> filetests are based on this value. |
2918 | 2065 | |
2919 | 2066 | =end original |
2920 | 2067 | |
2921 | 2068 | プログラムを実行開始した時刻を、紀元 (1970年の始め) からの秒数で示したものです。 |
2922 | 2069 | ファイルテスト B<-M>、B<-A>、B<-C> で返される値は、この値に基づいています。 |
2923 | 2070 | |
2924 | =item ${^TAINT} | |
2925 | ||
2926 | =begin original | |
2927 | ||
2928 | Reflects if taint mode is on or off. 1 for on (the program was run with | |
2929 | B<-T>), 0 for off, -1 when only taint warnings are enabled (i.e. with | |
2930 | B<-t> or B<-TU>). This variable is read-only. | |
2931 | ||
2932 | =end original | |
2933 | ||
2934 | 汚染検査モードのオン・オフを反映します。 | |
2935 | 1 はオン(プログラムは B<-T> 付きで実行されている)、0 はオフ、-1 は汚染 | |
2936 | 警告のみが有効になっている(つまり B<-t> か B<-TU>)ことを意味します。 | |
2937 | この変数は読み込み専用です。 | |
2938 | ||
2939 | =item ${^UNICODE} | |
2940 | ||
2941 | =begin original | |
2942 | ||
2943 | Reflects certain Unicode settings of Perl. See L<perlrun> | |
2944 | documentation for the C<-C> switch for more information about | |
2945 | the possible values. This variable is set during Perl startup | |
2946 | and is thereafter read-only. | |
2947 | ||
2948 | =end original | |
2949 | ||
2950 | Perl のいくつかの Unicode 設定を反映します。 | |
2951 | 設定できる値に関するさらなる情報については L<perlrun> の C<-C> オプションを | |
2952 | 参照してください。 | |
2953 | この変数は Perl 起動時に設定され、その後は読み込み専用です。 | |
2954 | ||
2955 | =item ${^UTF8CACHE} | |
2956 | ||
2957 | =begin original | |
2958 | ||
2959 | This variable controls the state of the internal UTF-8 offset caching code. | |
2960 | 1 for on (the default), 0 for off, -1 to debug the caching code by checking | |
2961 | all its results against linear scans, and panicking on any discrepancy. | |
2962 | ||
2963 | =end original | |
2964 | ||
2965 | この変数は内部 UTF-8 オフセットキャッシュコードの状態を制御します。 | |
2966 | 1 はオン(デフォルト)、0 はオフ、-1 は全ての結果を線形走査と比較して、 | |
2967 | 矛盾があれば異常終了する、という形でキャッシュコードをデバッグします。 | |
2968 | ||
2969 | =item ${^UTF8LOCALE} | |
2970 | ||
2971 | =begin original | |
2972 | ||
2973 | This variable indicates whether an UTF-8 locale was detected by perl at | |
2974 | startup. This information is used by perl when it's in | |
2975 | adjust-utf8ness-to-locale mode (as when run with the C<-CL> command-line | |
2976 | switch); see L<perlrun> for more info on this. | |
2977 | ||
2978 | =end original | |
2979 | ||
2980 | この変数は、起動時に perl によって UTF-8 ロケールが検出されたかどうかを | |
2981 | 示します。 | |
2982 | この情報は(C<-CL> コマンドラインスイッチで起動されることによって) | |
2983 | 「utf8 性をロケールに合わせる」モードのときに perl によって使われます; | |
2984 | これに関するさらなる情報は L<perlrun> を参照してください。 | |
2985 | ||
2986 | 2071 | =item $PERL_VERSION |
2987 | 2072 | |
2988 | 2073 | =item $^V |
2989 | X<$^V> X<$PERL_VERSION> | |
2990 | 2074 | |
2991 | 2075 | =begin original |
2992 | 2076 | |
2993 | 2077 | The revision, version, and subversion of the Perl interpreter, represented |
2994 | as a | |
2078 | as a string composed of characters with those ordinals. Thus in Perl v5.6.0 | |
2079 | it equals C<chr(5) . chr(6) . chr(0)> and will return true for | |
2080 | C<$^V eq v5.6.0>. Note that the characters in this string value can | |
2081 | potentially be in Unicode range. | |
2995 | 2082 | |
2996 | 2083 | =end original |
2997 | 2084 | |
2998 | ||
2085 | Perl インタプリタの revision, version, subversion を | |
2086 | それぞれの序数の文字からなる文字列で表現します。 | |
2087 | つまり Perl v5.6.0 では C<chr(5) . chr(6) . chr(0)> となり、 | |
2088 | C<$^V eq v5.6.0> は真を返します。 | |
2089 | この文字列の文字は Unicode の範囲に入るかもしれないことに注意してください。 | |
2999 | 2090 | |
3000 | 2091 | =begin original |
3001 | 2092 | |
3002 | This | |
2093 | This can be used to determine whether the Perl interpreter executing a | |
3003 | see an undefined value. Before perl 5.10.0 $^V was represented as a v-string. | |
3004 | ||
3005 | =end original | |
3006 | ||
3007 | この変数は perl 5.6.0 で最初に現れました; それより前のバージョンでは | |
3008 | 未定義値となります。 | |
3009 | perl 5.10.0 以前では $^V は v-string 形式で表現されます。 | |
3010 | ||
3011 | =begin original | |
3012 | ||
3013 | $^V can be used to determine whether the Perl interpreter executing a | |
3014 | 2094 | script is in the right range of versions. (Mnemonic: use ^V for Version |
3015 | 2095 | Control.) Example: |
3016 | 2096 | |
3017 | 2097 | =end original |
3018 | 2098 | |
3019 | ||
2099 | これはスクリプトを実行している Perl インタプリタのバージョンが | |
3020 | 2100 | 正しい範囲に入っているかを調べるのに使えます。(記憶法: |
3021 | 2101 | ^V をバージョンコントロールに使います。) 例: |
3022 | 2102 | |
3023 | warn " | |
2103 | warn "No \"our\" declarations!\n" if $^V and $^V lt v5.6.0; | |
3024 | 2104 | |
3025 | 2105 | =begin original |
3026 | 2106 | |
3027 | To convert C<$^V> into its string representation use sprintf()'s | |
3028 | C<"%vd"> conversion: | |
3029 | ||
3030 | =end original | |
3031 | ||
3032 | C<$^V> を文字列表現に変換するには sprintf() の C<"%vd"> 変換を使います: | |
3033 | ||
3034 | printf "version is v%vd\n", $^V; # Perl's version | |
3035 | ||
3036 | =begin original | |
3037 | ||
3038 | 2107 | See the documentation of C<use VERSION> and C<require VERSION> |
3039 | 2108 | for a convenient way to fail if the running Perl interpreter is too old. |
3040 | 2109 | |
3041 | 2110 | =end original |
3042 | 2111 | |
3043 | 2112 | 実行する Perl インタプリタが古すぎる場合に終了する便利な方法に |
3044 | 2113 | ついては C<use VERSION> と C<require VERSION> のドキュメントを |
3045 | 2114 | 参照して下さい。 |
3046 | 2115 | |
3047 | 2116 | =begin original |
3048 | 2117 | |
3049 | 2118 | See also C<$]> for an older representation of the Perl version. |
3050 | 2119 | |
3051 | 2120 | =end original |
3052 | 2121 | |
3053 | 2122 | Perl バージョンの古い表現については C<$]> も参照して下さい。 |
3054 | 2123 | |
3055 | 2124 | =item $WARNING |
3056 | 2125 | |
3057 | 2126 | =item $^W |
3058 | X<$^W> X<$WARNING> | |
3059 | 2127 | |
3060 | 2128 | =begin original |
3061 | 2129 | |
3062 | 2130 | The current value of the warning switch, initially true if B<-w> |
3063 | 2131 | was used, false otherwise, but directly modifiable. (Mnemonic: |
3064 | 2132 | related to the B<-w> switch.) See also L<warnings>. |
3065 | 2133 | |
3066 | 2134 | =end original |
3067 | 2135 | |
3068 | 2136 | 警告スイッチの値で、B<-w> スイッチが使われると内部的に真となり、 |
3069 | 2137 | そうでない場合は直接変更可能です。 |
3070 | 2138 | (記憶法: B<-w> スイッチに関係します。) |
3071 | 2139 | L<warnings> も参照して下さい。 |
3072 | 2140 | |
3073 | 2141 | =item ${^WARNING_BITS} |
3074 | 2142 | |
3075 | 2143 | =begin original |
3076 | 2144 | |
3077 | 2145 | The current set of warning checks enabled by the C<use warnings> pragma. |
3078 | 2146 | See the documentation of C<warnings> for more details. |
3079 | 2147 | |
3080 | 2148 | =end original |
3081 | 2149 | |
3082 | 2150 | C<use warnings> プラグマで有効にされた、現在の警告チェックの集合です。 |
3083 | 2151 | 詳細については C<warnings> のドキュメントを参照して下さい。 |
3084 | 2152 | |
3085 | =item ${^WI | |
2153 | =item ${^WIDE_SYSTEM_CALLS} | |
3086 | 2154 | |
3087 | 2155 | =begin original |
3088 | 2156 | |
3089 | ||
2157 | Global flag that enables system calls made by Perl to use wide character | |
3090 | n | |
2158 | APIs native to the system, if available. This is currently only implemented | |
3091 | ||
2159 | on the Windows platform. | |
3092 | hardlinks to the file exist. On the other hand, not opening the file | |
3093 | is considerably faster, especially for files on network drives. | |
3094 | 2160 | |
3095 | 2161 | =end original |
3096 | 2162 | |
3097 | ||
2163 | Perl によるシステムコールで、システムにネイティブなワイド文字 API を | |
3098 | ||
2164 | (もし使えるなら)使うようにするグローバルフラグです。 | |
3099 | これは | |
2165 | これは現在 Windows プラットフォームでのみ実装されています。 | |
3100 | 決定できませんし、ファイル属性が古いものになるかもしれないことを | |
3101 | 意味します。 | |
3102 | 一方、ファイルを開かないので、(特にファイルがネットワークドライブにある | |
3103 | 場合は)大幅に高速です。 | |
3104 | 2166 | |
3105 | 2167 | =begin original |
3106 | 2168 | |
3107 | This | |
2169 | This can also be enabled from the command line using the C<-C> switch. | |
3108 | configure the local Perl installation to use "sloppy" stat() by | |
3109 | default. See L<perlrun> for more information about site | |
3110 | customization. | |
3111 | 2170 | |
3112 | 2171 | =end original |
3113 | 2172 | |
3114 | ||
2173 | これはコマンドラインで C<-C> スイッチを使うことでも有効になります。 | |
3115 | Perl を設定するための F<sitecustomize.pl> で設定できます。 | |
3116 | サイトカスタマイズに関するさらなる情報については L<perlrun> を | |
3117 | 参照してください。 | |
3118 | 2174 | |
3119 | =item $EXECUTABLE_NAME | |
3120 | ||
3121 | =item $^X | |
3122 | X<$^X> X<$EXECUTABLE_NAME> | |
3123 | ||
3124 | 2175 | =begin original |
3125 | 2176 | |
3126 | The na | |
2177 | The initial value is typically C<0> for compatibility with Perl versions | |
3127 | ||
2178 | earlier than 5.6, but may be automatically set to C<1> by Perl if the system | |
2179 | provides a user-settable default (e.g., C<$ENV{LC_CTYPE}>). | |
3128 | 2180 | |
3129 | 2181 | =end original |
3130 | 2182 | |
3131 | Perl バ | |
2183 | 初期値は典型的には C<0> で、これは Perl バージョン 5.6 以前との | |
3132 | ||
2184 | 互換性のためです。 | |
2185 | しかし、システムがユーザー定義可能なデフォルト(C<$ENV{LC_CTYPE}> など)を | |
2186 | 提供している場合は、Perl によって自動的に C<1> にセットされることもあります。 | |
3133 | 2187 | |
3134 | 2188 | =begin original |
3135 | 2189 | |
3136 | ||
2190 | The C<bytes> pragma always overrides the effect of this flag in the current | |
3137 | ||
2191 | lexical scope. See L<bytes>. | |
3138 | be the string used to invoke perl but not the pathname of the | |
3139 | perl program file. Also, most operating systems permit invoking | |
3140 | programs that are not in the PATH environment variable, so there | |
3141 | is no guarantee that the value of $^X is in PATH. For VMS, the | |
3142 | value may or may not include a version number. | |
3143 | 2192 | |
3144 | 2193 | =end original |
3145 | 2194 | |
3146 | ||
2195 | C<bytes> プラグマは常に現在のレキシカルスコープでの | |
3147 | し | |
2196 | このフラグの効果を上書きします。L<bytes> を参照して下さい。 | |
3148 | 文字列ではありますが perl プログラムファイルのパス名ではないかもしれません。 | |
3149 | また、ほとんどの OS は PATH 環境変数にない位置のプログラムを起動することを | |
3150 | 許しているので、$^X の値が PATH にある保証はありません。 | |
3151 | VMS では、この値はバージョン番号を含む場合も含まない場合もあります。 | |
3152 | 2197 | |
3153 | = | |
2198 | =item $EXECUTABLE_NAME | |
3154 | 2199 | |
3155 | ||
2200 | =item $^X | |
3156 | copy of the same perl that is currently running, e.g., | |
3157 | 2201 | |
3158 | =end original | |
3159 | ||
3160 | 通常は、現在実行中のものと同じ perl の独立したコピーを再起動するために | |
3161 | $^X の値を使えます; つまり: | |
3162 | ||
3163 | @first_run = `$^X -le "print int rand 100 for 1..100"`; | |
3164 | ||
3165 | 2202 | =begin original |
3166 | 2203 | |
3167 | ||
2204 | The name that the Perl binary itself was executed as, from C's C<argv[0]>. | |
3168 | ||
2205 | This may not be a full pathname, nor even necessarily in your path. | |
3169 | may not be portable. | |
3170 | 2206 | |
3171 | 2207 | =end original |
3172 | 2208 | |
3173 | ||
2209 | Perl バイナリ自身が実行された時の名前を C の argv[0] から持ってきたものです。 | |
3174 | ||
2210 | フルパスではないかもしれませんし、検索パスにないかもしれません。 | |
3175 | 2211 | |
3176 | =begin original | |
3177 | ||
3178 | It is not safe to use the value of $^X as a path name of a file, | |
3179 | as some operating systems that have a mandatory suffix on | |
3180 | executable files do not require use of the suffix when invoking | |
3181 | a command. To convert the value of $^X to a path name, use the | |
3182 | following statements: | |
3183 | ||
3184 | =end original | |
3185 | ||
3186 | $^X の値をファイルのパス名として使うのは安全ではありません; | |
3187 | 実行ファイルに固定の接尾辞があり、コマンドの起動時には接尾辞が不要な OS も | |
3188 | あるからです。 | |
3189 | $^X の値をパス名に変換するには、以下のコードを使ってください: | |
3190 | ||
3191 | # Build up a set of file names (not command names). | |
3192 | use Config; | |
3193 | $this_perl = $^X; | |
3194 | if ($^O ne 'VMS') | |
3195 | {$this_perl .= $Config{_exe} | |
3196 | unless $this_perl =~ m/$Config{_exe}$/i;} | |
3197 | ||
3198 | =begin original | |
3199 | ||
3200 | Because many operating systems permit anyone with read access to | |
3201 | the Perl program file to make a copy of it, patch the copy, and | |
3202 | then execute the copy, the security-conscious Perl programmer | |
3203 | should take care to invoke the installed copy of perl, not the | |
3204 | copy referenced by $^X. The following statements accomplish | |
3205 | this goal, and produce a pathname that can be invoked as a | |
3206 | command or referenced as a file. | |
3207 | ||
3208 | =end original | |
3209 | ||
3210 | 多くの OS が Perl のプログラムファイルのコピーを作って、コピーに | |
3211 | パッチを当て、それを実行するための読み込み権限を全員に与えているので、 | |
3212 | セキュリティ意識のある Perl プログラマは $^X で参照されているコピーではなく、 | |
3213 | インストールされている perl を起動するように気をつけるべきです。 | |
3214 | 以下のコードはこの目的を達成し、コマンドとして起動したりファイルとして | |
3215 | 参照するためのパス名を作成します。 | |
3216 | ||
3217 | use Config; | |
3218 | $secure_perl_path = $Config{perlpath}; | |
3219 | if ($^O ne 'VMS') | |
3220 | {$secure_perl_path .= $Config{_exe} | |
3221 | unless $secure_perl_path =~ m/$Config{_exe}$/i;} | |
3222 | ||
3223 | =item ARGV | |
3224 | X<ARGV> | |
3225 | ||
3226 | =begin original | |
3227 | ||
3228 | The special filehandle that iterates over command-line filenames in | |
3229 | C<@ARGV>. Usually written as the null filehandle in the angle operator | |
3230 | C<< <> >>. Note that currently C<ARGV> only has its magical effect | |
3231 | within the C<< <> >> operator; elsewhere it is just a plain filehandle | |
3232 | corresponding to the last file opened by C<< <> >>. In particular, | |
3233 | passing C<\*ARGV> as a parameter to a function that expects a filehandle | |
3234 | may not cause your function to automatically read the contents of all the | |
3235 | files in C<@ARGV>. | |
3236 | ||
3237 | =end original | |
3238 | ||
3239 | C<@ARGV> にあるコマンドラインで指定されたファイル名に対して反復する | |
3240 | 特殊ファイルハンドルです。 | |
3241 | 通常角かっこ C<< <> >> の中で空ファイルハンドルとして書かれます。 | |
3242 | 現在のところ、C<ARGV> は C<< <> >> 演算子の中でのみ特別な効果があることに | |
3243 | 注意してください; その他の場所では、C<< <> >> で開かれた最後のファイルに | |
3244 | 対応する普通のファイルハンドルです。 | |
3245 | 特に、ファイルハンドルを想定している関数に C<\*ARGV> を引数として渡しても、 | |
3246 | 関数内で C<@ARGV> にある全てのファイルの内容を自動的に読み込むことには | |
3247 | なりません。 | |
3248 | ||
3249 | 2212 | =item $ARGV |
3250 | X<$ARGV> | |
3251 | 2213 | |
3252 | 2214 | =begin original |
3253 | 2215 | |
3254 | 2216 | contains the name of the current file when reading from <>. |
3255 | 2217 | |
3256 | 2218 | =end original |
3257 | 2219 | |
3258 | 2220 | <> から読込みを行なっているとき、その時点のファイル名を示します。 |
3259 | 2221 | |
3260 | 2222 | =item @ARGV |
3261 | X<@ARGV> | |
3262 | 2223 | |
3263 | 2224 | =begin original |
3264 | 2225 | |
3265 | 2226 | The array @ARGV contains the command-line arguments intended for |
3266 | 2227 | the script. C<$#ARGV> is generally the number of arguments minus |
3267 | 2228 | one, because C<$ARGV[0]> is the first argument, I<not> the program's |
3268 | 2229 | command name itself. See C<$0> for the command name. |
3269 | 2230 | |
3270 | 2231 | =end original |
3271 | 2232 | |
3272 | 2233 | 配列 @ARGV は、コマンドラインからスクリプトに渡す引数が入れられます。 |
3273 | 2234 | C<$ARGV[0]> がI<プログラムのコマンド名自身ではなく>、 |
3274 | 2235 | 最初の引数ですから、C<$#ARGV> は一般には、引数の個数 - 1 となります。 |
3275 | 2236 | コマンド名については、C<$0> を参照してください。 |
3276 | 2237 | |
3277 | =item ARGVOUT | |
3278 | X<ARGVOUT> | |
3279 | ||
3280 | =begin original | |
3281 | ||
3282 | The special filehandle that points to the currently open output file | |
3283 | when doing edit-in-place processing with B<-i>. Useful when you have | |
3284 | to do a lot of inserting and don't want to keep modifying $_. See | |
3285 | L<perlrun> for the B<-i> switch. | |
3286 | ||
3287 | =end original | |
3288 | ||
3289 | B<-i> を使ってその場修正を行っているときに、現在開いている出力ファイルを | |
3290 | 示す特殊ファイルハンドルです。 | |
3291 | たくさんの挿入をする必要があるときに $_ を修正し続けたくない場合に | |
3292 | 有用です。 | |
3293 | B<-i> オプションについては L<perlrun> を参照してください。 | |
3294 | ||
3295 | =item @F | |
3296 | X<@F> | |
3297 | ||
3298 | =begin original | |
3299 | ||
3300 | The array @F contains the fields of each line read in when autosplit | |
3301 | mode is turned on. See L<perlrun> for the B<-a> switch. This array | |
3302 | is package-specific, and must be declared or given a full package name | |
3303 | if not in package main when running under C<strict 'vars'>. | |
3304 | ||
3305 | =end original | |
3306 | ||
3307 | 自動 split モードが有効の場合、配列 @F には読み込んだ行のフィールドを | |
3308 | 含みます。 | |
3309 | B<-a> オプションについては L<perlrun> を参照してください。 | |
3310 | この配列はパッケージ固有であり、もし C<strict 'vars'> で実行していて | |
3311 | パッケージ main 以外の場合は完全なパッケージ名で定義したり与えたり | |
3312 | しなければなりません。 | |
3313 | ||
3314 | 2238 | =item @INC |
3315 | X<@INC> | |
3316 | 2239 | |
3317 | 2240 | =begin original |
3318 | 2241 | |
3319 | 2242 | The array @INC contains the list of places that the C<do EXPR>, |
3320 | 2243 | C<require>, or C<use> constructs look for their library files. It |
3321 | 2244 | initially consists of the arguments to any B<-I> command-line |
3322 | 2245 | switches, followed by the default Perl library, probably |
3323 | 2246 | F</usr/local/lib/perl>, followed by ".", to represent the current |
3324 | directory. | |
2247 | directory. If you need to modify this at runtime, you should use | |
3325 | C<-T> or by C<-t>.) If you need to modify this at runtime, you should use | |
3326 | 2248 | the C<use lib> pragma to get the machine-dependent library properly |
3327 | 2249 | loaded also: |
3328 | 2250 | |
3329 | 2251 | =end original |
3330 | 2252 | |
3331 | 2253 | 配列 @INC には、do EXPR、require、use によってライブラリファイルを |
3332 | 2254 | 探すときに評価する場所のリストが納められています。 |
3333 | 2255 | 初期状態では、コマンドラインスイッチ B<-I> の引数と |
3334 | 2256 | デフォルトの Perl ライブラリディレクトリ (おそらく |
3335 | 2257 | F</usr/local/lib/perl5>) とカレントディレクトリを表わす |
3336 | 2258 | "." を順につなげたものです。 |
3337 | ||
2259 | 実行時にこれを変更する必要がある場合は、 | |
3338 | ||
2260 | マシン依存のライブラリを正しく読み込むために C<use lib> も使うべきです: | |
3339 | 読み込むために C<use lib> を使うべきです: | |
3340 | 2261 | |
3341 | 2262 | use lib '/mypath/libdir/'; |
3342 | 2263 | use SomeMod; |
3343 | 2264 | |
3344 | =begin original | |
3345 | ||
3346 | You can also insert hooks into the file inclusion system by putting Perl | |
3347 | code directly into @INC. Those hooks may be subroutine references, array | |
3348 | references or blessed objects. See L<perlfunc/require> for details. | |
3349 | ||
3350 | =end original | |
3351 | ||
3352 | Perl のコードを直接 @INC に入れることで、ファイルインクルード機構に | |
3353 | フックを挿入できます。 | |
3354 | このフックはサブルーチンリファレンス、配列リファレンス、bless された | |
3355 | オブジェクトが可能です。 | |
3356 | 詳細については L<perlfunc/require> を参照してください。 | |
3357 | ||
3358 | =item @ARG | |
3359 | ||
3360 | 2265 | =item @_ |
3361 | X<@_> X<@ARG> | |
3362 | 2266 | |
3363 | 2267 | =begin original |
3364 | 2268 | |
3365 | 2269 | Within a subroutine the array @_ contains the parameters passed to that |
3366 | 2270 | subroutine. See L<perlsub>. |
3367 | 2271 | |
3368 | 2272 | =end original |
3369 | 2273 | |
3370 | 2274 | サブルーチンの内部では、配列 @_ はサブルーチンに渡されたパラメータです。 |
3371 | 2275 | L<perlsub> を参照して下さい。 |
3372 | 2276 | |
3373 | 2277 | =item %INC |
3374 | X<%INC> | |
3375 | 2278 | |
3376 | 2279 | =begin original |
3377 | 2280 | |
3378 | 2281 | The hash %INC contains entries for each filename included via the |
3379 | 2282 | C<do>, C<require>, or C<use> operators. The key is the filename |
3380 | 2283 | you specified (with module names converted to pathnames), and the |
3381 | 2284 | value is the location of the file found. The C<require> |
3382 | 2285 | operator uses this hash to determine whether a particular file has |
3383 | 2286 | already been included. |
3384 | 2287 | |
3385 | 2288 | =end original |
3386 | 2289 | |
3387 | 2290 | ハッシュ %INC は、C<do>, C<require>, C<use>演算子によって |
3388 | 2291 | インクルードされた、個々のファイル名をエントリとして持っています。 |
3389 | 2292 | key は指定したファイル名(モジュール名はパス名に変換されます)で、 |
3390 | 2293 | value は見つかった場所となっています。 |
3391 | 2294 | C<require> 演算子は、指定されたファイル名が既に |
3392 | 2295 | インクルードされているかを、このハッシュを使って調べます。 |
3393 | 2296 | |
3394 | =begin original | |
3395 | ||
3396 | If the file was loaded via a hook (e.g. a subroutine reference, see | |
3397 | L<perlfunc/require> for a description of these hooks), this hook is | |
3398 | by default inserted into %INC in place of a filename. Note, however, | |
3399 | that the hook may have set the %INC entry by itself to provide some more | |
3400 | specific info. | |
3401 | ||
3402 | =end original | |
3403 | ||
3404 | ファイルがフック(つまりサブルーチンリファレンス; フックに関する | |
3405 | 説明については L<perlfunc/require> を参照してください)経由で読み込まれた | |
3406 | 場合、このフックはデフォルトではファイル名の代わりに %INC に挿入されます。 | |
3407 | しかし、フックはさらなる特定の情報を提供するために、自身で %INC エントリを | |
3408 | セットするかもしれないことに注意してください。 | |
3409 | ||
3410 | 2297 | =item %ENV |
3411 | 2298 | |
3412 | 2299 | =item $ENV{expr} |
3413 | X<%ENV> | |
3414 | 2300 | |
3415 | 2301 | =begin original |
3416 | 2302 | |
3417 | 2303 | The hash %ENV contains your current environment. Setting a |
3418 | 2304 | value in C<ENV> changes the environment for any child processes |
3419 | 2305 | you subsequently fork() off. |
3420 | 2306 | |
3421 | 2307 | =end original |
3422 | 2308 | |
3423 | 2309 | ハッシュ %ENV には、その時点の環境変数が設定されています。 |
3424 | 2310 | C<ENV> に値を設定することで、 |
3425 | 2311 | 以後に fork() した子プロセスの環境変数を変更します。 |
3426 | 2312 | |
3427 | 2313 | =item %SIG |
3428 | 2314 | |
3429 | 2315 | =item $SIG{expr} |
3430 | X<%SIG> | |
3431 | 2316 | |
3432 | 2317 | =begin original |
3433 | 2318 | |
3434 | The hash | |
2319 | The hash %SIG contains signal handlers for signals. For example: | |
3435 | 2320 | |
3436 | 2321 | =end original |
3437 | 2322 | |
3438 | ハッシュ | |
2323 | ハッシュ %SIG にはシグナルのためのシグナルハンドラが含まれています。例: | |
3439 | 例えば: | |
3440 | 2324 | |
3441 | 2325 | sub handler { # 1st argument is signal name |
3442 | 2326 | my($sig) = @_; |
3443 | 2327 | print "Caught a SIG$sig--shutting down\n"; |
3444 | 2328 | close(LOG); |
3445 | 2329 | exit(0); |
3446 | 2330 | } |
3447 | 2331 | |
3448 | 2332 | $SIG{'INT'} = \&handler; |
3449 | 2333 | $SIG{'QUIT'} = \&handler; |
3450 | 2334 | ... |
3451 | 2335 | $SIG{'INT'} = 'DEFAULT'; # restore default action |
3452 | 2336 | $SIG{'QUIT'} = 'IGNORE'; # ignore SIGQUIT |
3453 | 2337 | |
3454 | 2338 | =begin original |
3455 | 2339 | |
3456 | 2340 | Using a value of C<'IGNORE'> usually has the effect of ignoring the |
3457 | 2341 | signal, except for the C<CHLD> signal. See L<perlipc> for more about |
3458 | 2342 | this special case. |
3459 | 2343 | |
3460 | 2344 | =end original |
3461 | 2345 | |
3462 | 2346 | C<'IGNORE'> という値は通常はシグナルの効果を無視するために使いますが、 |
3463 | 2347 | C<CHLD> シグナルは例外です。 |
3464 | 2348 | この特別な場合に関する詳細は L<perlipc> を参照して下さい。 |
3465 | 2349 | |
3466 | 2350 | =begin original |
3467 | 2351 | |
3468 | 2352 | Here are some other examples: |
3469 | 2353 | |
3470 | =end original | |
3471 | ||
3472 | 以下にその他の例を示します: | |
3473 | ||
3474 | =begin original | |
3475 | ||
3476 | 2354 | $SIG{"PIPE"} = "Plumber"; # assumes main::Plumber (not recommended) |
3477 | 2355 | $SIG{"PIPE"} = \&Plumber; # just fine; assume current Plumber |
3478 | 2356 | $SIG{"PIPE"} = *Plumber; # somewhat esoteric |
3479 | 2357 | $SIG{"PIPE"} = Plumber(); # oops, what did Plumber() return?? |
3480 | 2358 | |
3481 | 2359 | =end original |
3482 | 2360 | |
2361 | 以下にその他の例を示します: | |
2362 | ||
3483 | 2363 | $SIG{"PIPE"} = "Plumber"; # main::Plumber を仮定します(非推奨) |
3484 | 2364 | $SIG{"PIPE"} = \&Plumber; # 問題なし; カレントの Plumber を仮定します |
3485 | 2365 | $SIG{"PIPE"} = *Plumber; # 少々難解 |
3486 | 2366 | $SIG{"PIPE"} = Plumber(); # げげ、Plumber() は何を返すの?? |
3487 | 2367 | |
3488 | 2368 | =begin original |
3489 | 2369 | |
3490 | 2370 | Be sure not to use a bareword as the name of a signal handler, |
3491 | 2371 | lest you inadvertently call it. |
3492 | 2372 | |
3493 | 2373 | =end original |
3494 | 2374 | |
3495 | 2375 | 裸の単語をシグナルハンドラの名前として使わないようにしてください。 |
3496 | 2376 | 不注意で呼び出すのを避けるためです。 |
3497 | 2377 | |
3498 | 2378 | =begin original |
3499 | 2379 | |
3500 | 2380 | If your system has the sigaction() function then signal handlers are |
3501 | installed using it. This means you get reliable signal handling. | |
2381 | installed using it. This means you get reliable signal handling. If | |
2382 | your system has the SA_RESTART flag it is used when signals handlers are | |
2383 | installed. This means that system calls for which restarting is supported | |
2384 | continue rather than returning when a signal arrives. If you want your | |
2385 | system calls to be interrupted by signal delivery then do something like | |
2386 | this: | |
3502 | 2387 | |
3503 | 2388 | =end original |
3504 | 2389 | |
3505 | 2390 | システムに sigaction() 関数がある場合は、 |
3506 | 2391 | シグナルハンドラはこの関数を使って設定されます。 |
3507 | 2392 | これにより、信頼性のあるシグナルハンドリングが可能になります。 |
2393 | システムに SA_RESTART フラグがある場合は、 | |
2394 | シグナルハンドラはこれを使います。 | |
2395 | これによりこれにより再開に対応しているシステムコールは | |
2396 | シグナルが到着したときに返らずに再開します。 | |
2397 | シグナルが届いたときにシステムコールを中断したい場合は | |
2398 | 以下のようにしてください: | |
3508 | 2399 | |
2400 | use POSIX ':signal_h'; | |
2401 | ||
2402 | my $alarm = 0; | |
2403 | sigaction SIGALRM, new POSIX::SigAction sub { $alarm = 1 } | |
2404 | or die "Error setting SIGALRM handler: $!\n"; | |
2405 | ||
3509 | 2406 | =begin original |
3510 | 2407 | |
3511 | ||
2408 | See L<POSIX>. | |
3512 | immediate (also known as "unsafe") to deferred, also known as | |
3513 | "safe signals". See L<perlipc> for more information. | |
3514 | 2409 | |
3515 | 2410 | =end original |
3516 | 2411 | |
3517 | ||
2412 | L<POSIX> を参照して下さい。 | |
3518 | 知られます)から保留(「安全なシグナル」としても知られます)に変更されました。 | |
3519 | さらなる情報については L<perlipc> を参照してください。 | |
3520 | 2413 | |
3521 | 2414 | =begin original |
3522 | 2415 | |
3523 | 2416 | Certain internal hooks can be also set using the %SIG hash. The |
3524 | 2417 | routine indicated by C<$SIG{__WARN__}> is called when a warning message is |
3525 | 2418 | about to be printed. The warning message is passed as the first |
3526 | argument. The presence of a | |
2419 | argument. The presence of a __WARN__ hook causes the ordinary printing | |
3527 | of warnings to | |
2420 | of warnings to STDERR to be suppressed. You can use this to save warnings | |
3528 | 2421 | in a variable, or turn warnings into fatal errors, like this: |
3529 | 2422 | |
3530 | 2423 | =end original |
3531 | 2424 | |
3532 | 2425 | ある種の内部フックも %SIG ハッシュを使ってセットされます。 |
3533 | 2426 | 警告メッセージを表示しようとするときに C<$SIG{__WARN__}> で |
3534 | 2427 | 示されたルーチンが呼び出されます。 |
3535 | 2428 | 警告メッセージは最初の引数として渡されます。 |
3536 | ||
2429 | __WARN__ フックがあると、通常の STDERR への警告の出力は行われません。 | |
3537 | 2430 | これを使って、警告メッセージを変数にいれたり、 |
3538 | 2431 | あるいは以下のようにして警告を致命的エラーに変えたり出来ます: |
3539 | 2432 | |
3540 | 2433 | local $SIG{__WARN__} = sub { die $_[0] }; |
3541 | 2434 | eval $proggie; |
3542 | 2435 | |
3543 | 2436 | =begin original |
3544 | 2437 | |
3545 | As the C<'IGNORE'> hook is not supported by C<__WARN__>, you can | |
3546 | disable warnings using the empty subroutine: | |
3547 | ||
3548 | =end original | |
3549 | ||
3550 | C<__WARN__> では C<'IGNORE'> フックには対応していないので、空サブルーチンを | |
3551 | 使って警告を無効に出来ます: | |
3552 | ||
3553 | local $SIG{__WARN__} = sub {}; | |
3554 | ||
3555 | =begin original | |
3556 | ||
3557 | 2438 | The routine indicated by C<$SIG{__DIE__}> is called when a fatal exception |
3558 | 2439 | is about to be thrown. The error message is passed as the first |
3559 | argument. When a | |
2440 | argument. When a __DIE__ hook routine returns, the exception | |
3560 | 2441 | processing continues as it would have in the absence of the hook, |
3561 | unless the hook routine itself exits via a C<goto>, a loop exit, or a | |
2442 | unless the hook routine itself exits via a C<goto>, a loop exit, or a die(). | |
3562 | 2443 | The C<__DIE__> handler is explicitly disabled during the call, so that you |
3563 | 2444 | can die from a C<__DIE__> handler. Similarly for C<__WARN__>. |
3564 | 2445 | |
3565 | 2446 | =end original |
3566 | 2447 | |
3567 | 2448 | C<$SIG{__DIE__}> で示されるルーチンは |
3568 | 2449 | 致命的な例外がまさに投げられようとするときに呼び出されます。 |
3569 | 2450 | エラーメッセージは最初の引数として渡されます。 |
3570 | ||
2451 | __DIE__ フックから戻ると、 | |
3571 | 2452 | 例外処理はフックがなかったかのように再開されますが、 |
3572 | フックルーチン自体が C<goto>、ループ終了、 | |
2453 | フックルーチン自体が C<goto>、ループ終了、die() によって | |
3573 | 2454 | 終了した場合を除きます。 |
3574 | 2455 | C<__DIE__> ハンドラは呼び出し中は明示的に無効になりますので、 |
3575 | 2456 | C<__DIE__> ハンドラから die できます。 |
3576 | 2457 | C<__WARN__> も同様です。 |
3577 | 2458 | |
3578 | 2459 | =begin original |
3579 | 2460 | |
3580 | 2461 | Due to an implementation glitch, the C<$SIG{__DIE__}> hook is called |
3581 | 2462 | even inside an eval(). Do not use this to rewrite a pending exception |
3582 | in C<$@>, or as a bizarre substitute for overriding C | |
2463 | in C<$@>, or as a bizarre substitute for overriding CORE::GLOBAL::die(). | |
3583 | 2464 | This strange action at a distance may be fixed in a future release |
3584 | 2465 | so that C<$SIG{__DIE__}> is only called if your program is about |
3585 | 2466 | to exit, as was the original intent. Any other use is deprecated. |
3586 | 2467 | |
3587 | 2468 | =end original |
3588 | 2469 | |
3589 | 2470 | 実装上の不具合により、C<$SIG{__DIE__}> は eval() の中でも |
3590 | 2471 | 呼び出されます。これを、C<$@> の待っている例外を書き換えたり、 |
3591 | C | |
2472 | CORE::GLOBAL::die() を上書きするのに使わないでください。 | |
3592 | 2473 | この奇妙な行動は将来のリリースで修正される予定なので、 |
3593 | 2474 | C<$SIG{__DIE__}> は当初の目的通り、 |
3594 | 2475 | プログラムが終了するときにのみ呼び出されるようになります。 |
3595 | 2476 | その他の用途は非推奨です。 |
3596 | 2477 | |
3597 | 2478 | =begin original |
3598 | 2479 | |
3599 | 2480 | C<__DIE__>/C<__WARN__> handlers are very special in one respect: |
3600 | 2481 | they may be called to report (probable) errors found by the parser. |
3601 | 2482 | In such a case the parser may be in inconsistent state, so any |
3602 | 2483 | attempt to evaluate Perl code from such a handler will probably |
3603 | 2484 | result in a segfault. This means that warnings or errors that |
3604 | 2485 | result from parsing Perl should be used with extreme caution, like |
3605 | 2486 | this: |
3606 | 2487 | |
3607 | 2488 | =end original |
3608 | 2489 | |
3609 | 2490 | C<__DIE__> と C<__WARN__> のハンドラは一つの点で非常に特別です。 |
3610 | 2491 | パーザによってエラー(であろうもの)を報告するために呼び出されることがある |
3611 | 2492 | ことです。 |
3612 | 2493 | このような場合、パーザは不安定な状態になっているかもしれないので、 |
3613 | 2494 | ハンドラから Perl コードを評価しようとするとセグメンテーションフォールトが |
3614 | 2495 | 発生するかもしれません。 |
3615 | 2496 | Perl のパーズ中の警告やエラーは、以下のように非常に注意して扱うべきです。 |
3616 | 2497 | |
3617 | 2498 | require Carp if defined $^S; |
3618 | 2499 | Carp::confess("Something wrong") if defined &Carp::confess; |
3619 | 2500 | die "Something wrong, but could not load Carp to give backtrace... |
3620 | 2501 | To see backtrace try starting Perl with -MCarp switch"; |
3621 | 2502 | |
3622 | 2503 | =begin original |
3623 | 2504 | |
3624 | 2505 | Here the first line will load Carp I<unless> it is the parser who |
3625 | 2506 | called the handler. The second line will print backtrace and die if |
3626 | 2507 | Carp was available. The third line will be executed only if Carp was |
3627 | 2508 | not available. |
3628 | 2509 | |
3629 | 2510 | =end original |
3630 | 2511 | |
3631 | 2512 | 一行目は、I<パーザがハンドラを呼び出したのでなければ> |
3632 | 2513 | Carp を読み込みます。 |
3633 | 2514 | 二行目は、Carp が使えるならバックとレースを表示して die します。 |
3634 | 2515 | 三行目は Carp が使えないときにのみ実行されます。 |
3635 | 2516 | |
3636 | 2517 | =begin original |
3637 | 2518 | |
3638 | 2519 | See L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>, and |
3639 | 2520 | L<warnings> for additional information. |
3640 | 2521 | |
3641 | 2522 | =end original |
3642 | 2523 | |
3643 | 2524 | 追加の情報については L<perlfunc/die>, L<perlfunc/warn>, L<perlfunc/eval>, |
3644 | 2525 | L<warnings> を参照して下さい。 |
3645 | 2526 | |
3646 | 2527 | =back |
3647 | 2528 | |
3648 | 2529 | =head2 Error Indicators |
3649 | X<error> X<exception> | |
3650 | 2530 | |
3651 | 2531 | (エラー指示子) |
3652 | 2532 | |
3653 | 2533 | =begin original |
3654 | 2534 | |
3655 | 2535 | The variables C<$@>, C<$!>, C<$^E>, and C<$?> contain information |
3656 | 2536 | about different types of error conditions that may appear during |
3657 | 2537 | execution of a Perl program. The variables are shown ordered by |
3658 | 2538 | the "distance" between the subsystem which reported the error and |
3659 | 2539 | the Perl process. They correspond to errors detected by the Perl |
3660 | 2540 | interpreter, C library, operating system, or an external program, |
3661 | 2541 | respectively. |
3662 | 2542 | |
3663 | 2543 | =end original |
3664 | 2544 | |
3665 | 2545 | 変数 C<$@>, C<$!>, C<$^E>, C<$?> は Perl プログラムの実行中に |
3666 | 2546 | 発生した、異なる種類のエラー情報を保持します。 |
3667 | 2547 | 変数はエラーを報告した副システムと Perl プロセスとの「距離」 |
3668 | 2548 | の順番に並んでいます。 |
3669 | 2549 | これらはそれぞれ、Perl インタプリタ、C ライブラリ、 |
3670 | 2550 | オペレーティングシステム、外部プログラムによって検出された |
3671 | 2551 | エラーに対応しています。 |
3672 | 2552 | |
3673 | 2553 | =begin original |
3674 | 2554 | |
3675 | 2555 | To illustrate the differences between these variables, consider the |
3676 | 2556 | following Perl expression, which uses a single-quoted string: |
3677 | 2557 | |
3678 | 2558 | =end original |
3679 | 2559 | |
3680 | 2560 | これらの変数の違いを示すために、 |
3681 | 2561 | 以下のようなシングルクォートを用いた Perl 式を考えます: |
3682 | 2562 | |
3683 | 2563 | eval q{ |
3684 | open | |
2564 | open PIPE, "/cdrom/install |"; | |
3685 | | |
2565 | @res = <PIPE>; | |
3686 | close | |
2566 | close PIPE or die "bad pipe: $?, $!"; | |
3687 | 2567 | }; |
3688 | 2568 | |
3689 | 2569 | =begin original |
3690 | 2570 | |
3691 | 2571 | After execution of this statement all 4 variables may have been set. |
3692 | 2572 | |
3693 | 2573 | =end original |
3694 | 2574 | |
3695 | 2575 | この文を実行した後、4 つの変数全てがセットされる可能性があります。 |
3696 | 2576 | |
3697 | 2577 | =begin original |
3698 | 2578 | |
3699 | 2579 | C<$@> is set if the string to be C<eval>-ed did not compile (this |
3700 | 2580 | may happen if C<open> or C<close> were imported with bad prototypes), |
3701 | 2581 | or if Perl code executed during evaluation die()d . In these cases |
3702 | 2582 | the value of $@ is the compile error, or the argument to C<die> |
3703 | (which will interpolate C<$!> and C<$?>). (See also L<Fatal>, | |
2583 | (which will interpolate C<$!> and C<$?>!). (See also L<Fatal>, | |
3704 | 2584 | though.) |
3705 | 2585 | |
3706 | 2586 | =end original |
3707 | 2587 | |
3708 | 2588 | C<$@> は C<eval> された文字列がコンパイルされなかったとき |
3709 | 2589 | (これは C<open> か C<close> が正しくない |
3710 | 2590 | プロトタイプでインポートされたときに起こり得ます)、 |
3711 | 2591 | または評価中に実行している Perl コードが die() したときにセットされます。 |
3712 | 2592 | これらの場合には $@ の値はコンパイルエラー、または |
3713 | C<die> への引数(これには C<$!> と C<$?> が差し挟まれます)です。 | |
2593 | C<die> への引数(これには C<$!> と C<$?> が差し挟まれます!)です。 | |
3714 | 2594 | (しかし、L<Fatal> も参照して下さい。) |
3715 | 2595 | |
3716 | 2596 | =begin original |
3717 | 2597 | |
3718 | 2598 | When the eval() expression above is executed, open(), C<< <PIPE> >>, |
3719 | 2599 | and C<close> are translated to calls in the C run-time library and |
3720 | 2600 | thence to the operating system kernel. C<$!> is set to the C library's |
3721 | 2601 | C<errno> if one of these calls fails. |
3722 | 2602 | |
3723 | 2603 | =end original |
3724 | 2604 | |
3725 | 2605 | 上記の eval() 式が実行された後、 |
3726 | 2606 | open(), C<< <PIPE> >>, C<close> は C ランタイムライブラリの呼び出しに |
3727 | 2607 | 変換され、それからオペレーティングシステムコールに変換されます。 |
3728 | 2608 | C<$!> はこれらの呼び出しのどれかが失敗したとき、 |
3729 | 2609 | C ライブラリの C<errno> の値がセットされます。 |
3730 | 2610 | |
3731 | 2611 | =begin original |
3732 | 2612 | |
3733 | 2613 | Under a few operating systems, C<$^E> may contain a more verbose |
3734 | 2614 | error indicator, such as in this case, "CDROM tray not closed." |
3735 | 2615 | Systems that do not support extended error messages leave C<$^E> |
3736 | 2616 | the same as C<$!>. |
3737 | 2617 | |
3738 | 2618 | =end original |
3739 | 2619 | |
3740 | 2620 | いくつかのオペレーティングシステムでは、 |
3741 | 2621 | C<$^E> により詳細なエラー指示子が入っているかもしれません。 |
3742 | 2622 | 今回の場合で言えば、"CDROM tray not closed." などです。 |
3743 | 2623 | 追加のエラーメッセージに対応していないシステムでは、 |
3744 | 2624 | C<$^E> は C<$!> と同じ値です。 |
3745 | 2625 | |
3746 | 2626 | =begin original |
3747 | 2627 | |
3748 | 2628 | Finally, C<$?> may be set to non-0 value if the external program |
3749 | 2629 | F</cdrom/install> fails. The upper eight bits reflect specific |
3750 | 2630 | error conditions encountered by the program (the program's exit() |
3751 | 2631 | value). The lower eight bits reflect mode of failure, like signal |
3752 | 2632 | death and core dump information See wait(2) for details. In |
3753 | 2633 | contrast to C<$!> and C<$^E>, which are set only if error condition |
3754 | 2634 | is detected, the variable C<$?> is set on each C<wait> or pipe |
3755 | 2635 | C<close>, overwriting the old value. This is more like C<$@>, which |
3756 | 2636 | on every eval() is always set on failure and cleared on success. |
3757 | 2637 | |
3758 | 2638 | =end original |
3759 | 2639 | |
3760 | 2640 | 最後に、C<$?> は外部プログラム F</cdrom/install> が失敗したときに |
3761 | 2641 | 非 0 にセットされるかもしれません。 |
3762 | 2642 | 上位の 8 ビットはプログラムが遭遇した特定のエラー状況 |
3763 | 2643 | (プログラムの exit() の値)を反映します。 |
3764 | 2644 | 下位の 8 ビットは、シグナルの死亡やコアダンプ情報と言った失敗のモードを反映します。 |
3765 | 2645 | 詳細については wait(2) を参照して下さい。 |
3766 | 2646 | C<$!> と C<$^E> はエラー状況が検出されたときにのみ設定されますが、 |
3767 | 2647 | 変数 C<$?> は C<wait> やパイプの C<close> の度に、前の値を上書きします。 |
3768 | 2648 | これは、C<$@> が eval() の実行毎に、エラーならセットされ、 |
3769 | 2649 | 成功ならクリアされるという動作と似ています。 |
3770 | 2650 | |
3771 | 2651 | =begin original |
3772 | 2652 | |
3773 | 2653 | For more details, see the individual descriptions at C<$@>, C<$!>, C<$^E>, |
3774 | 2654 | and C<$?>. |
3775 | 2655 | |
3776 | 2656 | =end original |
3777 | 2657 | |
3778 | 2658 | より詳細については、C<$@>, C<$!>, C<$^E>, C<$?> それぞれの説明を |
3779 | 2659 | 参照して下さい。 |
3780 | 2660 | |
3781 | 2661 | =head2 Technical Note on the Syntax of Variable Names |
3782 | 2662 | |
3783 | 2663 | (変数名の文法に関するテクニカルノート) |
3784 | 2664 | |
3785 | 2665 | =begin original |
3786 | 2666 | |
3787 | 2667 | Variable names in Perl can have several formats. Usually, they |
3788 | 2668 | must begin with a letter or underscore, in which case they can be |
3789 | 2669 | arbitrarily long (up to an internal limit of 251 characters) and |
3790 | 2670 | may contain letters, digits, underscores, or the special sequence |
3791 | 2671 | C<::> or C<'>. In this case, the part before the last C<::> or |
3792 | 2672 | C<'> is taken to be a I<package qualifier>; see L<perlmod>. |
3793 | 2673 | |
3794 | 2674 | =end original |
3795 | 2675 | |
3796 | 2676 | Perl の変数名は様々な形があります。 |
3797 | 2677 | 通常、変数名は英文字か下線で始まらなければならず、 |
3798 | 2678 | 任意の長さ(内部制限の 251 文字まで)を取ることができ、 |
3799 | 2679 | 英文字、数字、下線、特別な文字列である C<::> と C<'> を含むことができます。 |
3800 | 2680 | この場合、最後の C<::> または C<'> の前は |
3801 | 2681 | I<パッケージ限定子> として扱われます。 |
3802 | 2682 | L<perlmod> を参照して下さい。 |
3803 | 2683 | |
3804 | 2684 | =begin original |
3805 | 2685 | |
3806 | 2686 | Perl variable names may also be a sequence of digits or a single |
3807 | 2687 | punctuation or control character. These names are all reserved for |
3808 | 2688 | special uses by Perl; for example, the all-digits names are used |
3809 | 2689 | to hold data captured by backreferences after a regular expression |
3810 | 2690 | match. Perl has a special syntax for the single-control-character |
3811 | 2691 | names: It understands C<^X> (caret C<X>) to mean the control-C<X> |
3812 | 2692 | character. For example, the notation C<$^W> (dollar-sign caret |
3813 | 2693 | C<W>) is the scalar variable whose name is the single character |
3814 | 2694 | control-C<W>. This is better than typing a literal control-C<W> |
3815 | 2695 | into your program. |
3816 | 2696 | |
3817 | 2697 | =end original |
3818 | 2698 | |
3819 | 2699 | Perl の変数は、数字の列または一文字の句読点かコントロール文字の |
3820 | 2700 | 場合もあります。 |
3821 | 2701 | これらの名前は全て Perl によって特別な用途のために予約されています。 |
3822 | 2702 | 例えば、全て数字の名前は正規表現マッチの後の後方参照のデータを |
3823 | 2703 | 保持するために用いられます。 |
3824 | 2704 | Perl には一文字のコントロール文字の名前のための特別な文法があります。 |
3825 | 2705 | C<^X>(キャレット C<X>)は control-C<X> キャラクタを意味します。 |
3826 | 2706 | 例えば、C<$^W>(ドル記号 キャレット C<W>)は control-C<W> 一文字の |
3827 | 2707 | 名前をもつスカラ変数です。 |
3828 | 2708 | これはプログラム中にリテラルな control-C<W> をタイプするより |
3829 | 2709 | 良いです。 |
3830 | 2710 | |
3831 | 2711 | =begin original |
3832 | 2712 | |
3833 | 2713 | Finally, new in Perl 5.6, Perl variable names may be alphanumeric |
3834 | 2714 | strings that begin with control characters (or better yet, a caret). |
3835 | 2715 | These variables must be written in the form C<${^Foo}>; the braces |
3836 | 2716 | are not optional. C<${^Foo}> denotes the scalar variable whose |
3837 | 2717 | name is a control-C<F> followed by two C<o>'s. These variables are |
3838 | 2718 | reserved for future special uses by Perl, except for the ones that |
3839 | 2719 | begin with C<^_> (control-underscore or caret-underscore). No |
3840 | 2720 | control-character name that begins with C<^_> will acquire a special |
3841 | 2721 | meaning in any future version of Perl; such names may therefore be |
3842 | 2722 | used safely in programs. C<$^_> itself, however, I<is> reserved. |
3843 | 2723 | |
3844 | 2724 | =end original |
3845 | 2725 | |
3846 | 2726 | 最後に、Perl 5.6 の新機能として、コントロール文字(もっと言えばキャレット)で |
3847 | 2727 | 始まる、英数字からなる文字列の変数名も使えます。 |
3848 | 2728 | これらの変数は C<${^Foo}> の形で書かれなければなりません。 |
3849 | 2729 | 括弧は必須です。 |
3850 | 2730 | C<${^Foo}> はコントロール-C<F> の後に二つ C<o> が続く名前を持つ |
3851 | 2731 | スカラ変数です。 |
3852 | 2732 | これらの変数は Perl によって特別な用途のために予約されていますが、 |
3853 | 2733 | C<^_> (コントロール-下線またはキャレット-下線)で始まるものは例外です。 |
3854 | 2734 | C<^_> で始まるコントロール文字名は Perl の将来のバージョンで |
3855 | 2735 | 特別な意味を持つことはありません。 |
3856 | 2736 | 従ってこれらの名前はプログラム中で安全に使用できます。 |
3857 | 2737 | 但し、C<$^_> そのものは I<予約されます>。 |
3858 | 2738 | |
3859 | 2739 | =begin original |
3860 | 2740 | |
3861 | 2741 | Perl identifiers that begin with digits, control characters, or |
3862 | 2742 | punctuation characters are exempt from the effects of the C<package> |
3863 | declaration and are always forced to be in package C<main> | |
2743 | declaration and are always forced to be in package C<main>. A few | |
3864 | ||
2744 | other names are also exempt: | |
3865 | exempt in these ways: | |
3866 | 2745 | |
3867 | 2746 | =end original |
3868 | 2747 | |
3869 | 2748 | 数字、コントロール文字、句読点で始まる Perl の識別子は |
3870 | 2749 | C<package> 宣言の効果から逃れて、常に C<main> パッケージにあるものとして |
3871 | 2750 | 扱われます。さらに以下のものも逃れます: |
3872 | 2751 | |
3873 | 2752 | ENV STDIN |
3874 | 2753 | INC STDOUT |
3875 | 2754 | ARGV STDERR |
3876 | ARGVOUT | |
2755 | ARGVOUT | |
3877 | 2756 | SIG |
3878 | 2757 | |
3879 | 2758 | =begin original |
3880 | 2759 | |
3881 | 2760 | In particular, the new special C<${^_XYZ}> variables are always taken |
3882 | 2761 | to be in package C<main>, regardless of any C<package> declarations |
3883 | presently in scope. | |
2762 | presently in scope. | |
3884 | 2763 | |
3885 | 2764 | =end original |
3886 | 2765 | |
3887 | 2766 | 特に、新しい特別な C<${^_XYZ}> 変数はスコープ内の C<package> 宣言に関わらず |
3888 | 2767 | 常に C<main> パッケージとして扱われます。 |
3889 | 2768 | |
3890 | 2769 | =head1 BUGS |
3891 | 2770 | |
3892 | 2771 | (バグ) |
3893 | 2772 | |
3894 | 2773 | =begin original |
3895 | 2774 | |
3896 | 2775 | Due to an unfortunate accident of Perl's implementation, C<use |
3897 | 2776 | English> imposes a considerable performance penalty on all regular |
3898 | 2777 | expression matches in a program, regardless of whether they occur |
3899 | 2778 | in the scope of C<use English>. For that reason, saying C<use |
3900 | 2779 | English> in libraries is strongly discouraged. See the |
3901 | 2780 | Devel::SawAmpersand module documentation from CPAN |
3902 | ( | |
2781 | (http://www.perl.com/CPAN/modules/by-module/Devel/) | |
3903 | for more information. | |
2782 | for more information. | |
3904 | avoids the performance penalty. | |
3905 | 2783 | |
3906 | 2784 | =end original |
3907 | 2785 | |
3908 | 2786 | Perl の実装における不幸な事故により、 |
3909 | 2787 | C<use English> はプログラム中の全ての正規表現マッチングにおいて |
3910 | 2788 | かなりの性能低下を引き起こします。 |
3911 | 2789 | これは C<use English> のスコープ内かどうかに関わりません。 |
3912 | 2790 | この理由により、ライブラリで C<use English> を使うのは |
3913 | 2791 | できるだけ避けてください。 |
3914 | 2792 | さらなる情報については CPAN の Devel::SawAmpersand モジュール |
3915 | 2793 | (http://www.perl.com/CPAN/modules/by-module/Devel/) の |
3916 | 2794 | ドキュメントを参照して下さい。 |
3917 | 2795 | |
3918 | 2796 | =begin original |
3919 | 2797 | |
3920 | 2798 | Having to even think about the C<$^S> variable in your exception |
3921 | 2799 | handlers is simply wrong. C<$SIG{__DIE__}> as currently implemented |
3922 | 2800 | invites grievous and difficult to track down errors. Avoid it |
3923 | 2801 | and use an C<END{}> or CORE::GLOBAL::die override instead. |
3924 | 2802 | |
3925 | 2803 | =end original |
3926 | 2804 | |
3927 | 2805 | 例外ハンドラの中で C<$^S> を使おうなどとは考えてもいけません。 |
3928 | 2806 | 現在の実装の C<$SIG{__DIE__}> は面倒を引き寄せ、エラーの追跡を困難にします。 |
3929 | 2807 | これの代わりに C<END{}> を使うか、CORE::GLOBAL::die をオーバーライドしてください。 |
3930 | 2808 | |
3931 | 2809 | =begin meta |
3932 | 2810 | |
3933 | 2811 | Translate: 吉村 寿人 <JAE00534@niftyserve.or.jp> (5.000) |
3934 | 2812 | Update: Kentaro Shirakata <argrath@ub32.org> (5.6.1-) |
2813 | License: GPL or Artistic | |
3935 | 2814 | |
3936 | 2815 | =end meta |