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