argra****@users*****
argra****@users*****
2008年 4月 23日 (水) 21:54:20 JST
Index: docs/perl/5.10.0/perlop.pod diff -u docs/perl/5.10.0/perlop.pod:1.4 docs/perl/5.10.0/perlop.pod:1.5 --- docs/perl/5.10.0/perlop.pod:1.4 Sun Apr 20 20:34:22 2008 +++ docs/perl/5.10.0/perlop.pod Wed Apr 23 21:54:20 2008 @@ -1251,15 +1251,17 @@ =end original -Although it has no direct equivalent in C, Perl's C<//> operator is related -to its C-style or. In fact, it's exactly the same as C<||>, except that it -tests the left hand side's definedness instead of its truth. Thus, C<$a // $b> -is similar to C<defined($a) || $b> (except that it returns the value of C<$a> -rather than the value of C<defined($a)>) and is exactly equivalent to -C<defined($a) ? $a : $b>. This is very useful for providing default values -for variables. If you actually want to test if at least one of C<$a> and -C<$b> is defined, use C<defined($a // $b)>. -(TBT) +C では直接等価なものはありませんが、 +Perl の C<//> 演算子は C スタイル論理和に関連しています。 +実際、左側は真偽はなく定義されているかを判定することを除けば +C<||> と同じです。 +したがって C<$a // $b> は C<defined($a) || $b> と似ていて (ただし、 +C<defined($a)> ではなく C<$a> の値を返します)、C<defined($a) ? $a : $b> と +完全に等価です。 +これは、変数に対するデフォルト値を設定するのにとても有用です。 +実際に望んでいることが、C<$a> と C<$b> の少なくとも片方が +定義されていることかを判定することなら、C<defined($a // $b)> を +使ってください。 =begin original @@ -2769,15 +2771,15 @@ =end original -Note that it's possible to confuse Perl into thinking C<//> (the empty -regex) is really C<//> (the defined-or operator). Perl is usually pretty -good about this, but some pathological cases might trigger this, such as -C<$a///> (is that C<($a) / (//)> or C<$a // />?) and C<print $fh //> -(C<print $fh(//> or C<print($fh //>?). In all of these examples, Perl -will assume you meant defined-or. If you meant the empty regex, just -use parentheses or spaces to disambiguate, or even prefix the empty -regex with an C<m> (so C<//> becomes C<m//>). -(TBT) +Perl が C<//> (空正規表現) と C<//> (定義性和演算子) を混同する +可能性があることに注意してください。 +Perl は普通これをかなりうまく処理しますが、C<$a///> (C<($a) / (//)> +それとも C<$a // />?) や C<print $fh //> (C<print $fh(//> それとも +C<print($fh //>?) のような病的な状況ではこれが起こりえます。 +これらの例の全てでは、Perl は定義性和を意味していると仮定します。 +もし空正規表現を意味したいなら、あいまいさをなくすために単に +かっこや空白を使うか、空正規表現に接頭辞 C<m> を付けてください +(つまり C<//> を C<m//> にします)。 =begin original @@ -3874,12 +3876,11 @@ =end original -Single quotes indicate the text is to be treated literally with no -interpolation of its content. This is similar to single quoted -strings except that backslashes have no special meaning, with C<\\> -being treated as two backslashes and not one as they would in every -other quoting construct. -(TBT) +シングルクォートは、内容が展開されずにリテラルに扱われることを +意味します。 +これはシングルクォート文字列と似ていますが、バックスラッシュは +特別な意味を持たず、他の全てのクォート構造違って、C<\\> は +二つのバックスラッシュとして扱われることが違います。 =begin original @@ -4182,15 +4183,14 @@ =end original -For the constructs except here-docs, single characters are used as starting -and ending delimiters. If the starting delimiter is an opening punctuation -(that is C<(>, C<[>, C<{>, or C<< < >>), the ending delimiter is the -corresponding closing punctuation (that is C<)>, C<]>, C<}>, or C<< > >>). -If the starting delimiter is an unpaired character like C</> or a closing -punctuation, the ending delimiter is same as the starting delimiter. -Therefore a C</> terminates a C<qq//> construct, while a C<]> terminates -C<qq[]> and C<qq]]> constructs. -(TBT) +ヒヤドキュメント以外の構造では、1 文字が開始デリミタと終了デリミタとして +使われます。 +開始デリミタが組の開き文字(C<(>, C<[>, C<{>, C<< < >> のいずれか)の場合、 +終了デリミタは対応する組の閉じ文字(つまり C<)>, C<]>, C<}>, C<< > >>) です。 +開始デリミタが C</> 組になる文字や、組の閉じ文字の場合、終了デリミタは +開始デリミタと同じです。 +従って C</> は C<qq//> 構造を終端し、一方 C<]> は C<qq[]> と C<qq]]> 構造を +終端します。 =begin original