[perldocjp-cvs 168] CVS update: docs/perl/5.6.1

アーカイブの一覧に戻る

Kentaro Shirakata argra****@users*****
2007年 7月 9日 (月) 02:39:33 JST


Index: docs/perl/5.6.1/perlfunc.pod
diff -u docs/perl/5.6.1/perlfunc.pod:1.13 docs/perl/5.6.1/perlfunc.pod:1.14
--- docs/perl/5.6.1/perlfunc.pod:1.13	Sun Jul  8 23:57:01 2007
+++ docs/perl/5.6.1/perlfunc.pod	Mon Jul  9 02:39:33 2007
@@ -144,6 +144,8 @@
 致命的でないエラーを示すために、スカラコンテキストでは
 未定義値を返し、リストコンテキストでは空リストを返します。
 
+=begin original
+
 Remember the following important rule: There is B<no rule> that relates
 the behavior of an expression in list context to its behavior in scalar
 context, or vice versa.  It might do two totally different things.
@@ -155,6 +157,22 @@
 operations.  In general, they do what you want, unless you want
 consistency.
 
+=end original
+
+以下に述べる重要なルールを忘れないで下さい: リストコンテキストでの
+振る舞いとスカラコンテキストでの振る舞いの関係、あるいはその逆に
+B<ルールはありません>。
+2 つの全く異なったことがあります。
+それぞれの演算子と関数は、スカラコンテキストでは、もっとも適切と
+思われる値を返します。
+リストコンテキストで返す時のリストの長さを返す演算子もあります。
+リストの最初の値を返す演算子もあります。
+リストの最後の値を返す演算子もあります。
+成功した操作の数を返す演算子もあります。
+一般的には、一貫性を求めない限り、こちらが求めることをします。
+
+=begin original
+
 An named array in scalar context is quite different from what would at
 first glance appear to be a list in scalar context.  You can't get a list
 like C<(1,2,3)> into being in scalar context, because the compiler knows
@@ -162,6 +180,17 @@
 there, not the list construction version of the comma.  That means it
 was never a list to start with.
 
+=end original
+
+スカラコンテキストでの名前付き配列は、スカラコンテキストでのリストを
+一目見たものとは全く違います。
+コンパイラはコンパイル時にコンテキストを知っているので、
+C<(1,2,3)> のようなリストをスカラコンテキストで得ることはできません。
+これはスカラコンマ演算子を生成し、コンマのリスト作成版ではありません。
+これは初めからリストであることはないことを意味します。
+
+=begin original
+
 In general, functions in Perl that serve as wrappers for system calls
 of the same name (like chown(2), fork(2), closedir(2), etc.) all return
 true when they succeed and C<undef> otherwise, as is usually mentioned
@@ -170,13 +199,33 @@
 C<waitpid>, and C<syscall>.  System calls also set the special C<$!>
 variable on failure.  Other functions do not, except accidentally.
 
+=end original
+
+一般的に、同じ名前のシステムコールのラッパーとして動作する Perl の関数
+(chown(2), fork(2), closedir(2) など)は、以下に述べるように、
+成功時に真を返し、そうでなければ C<undef> を返します。
+これは失敗時に C<-1> を返す C のインターフェースとは違います。
+このルールの例外は C<wait>, C<waitpid>, C<syscall> です。
+システムコールは失敗時に特殊変数 C<$!> をセットします。
+その他の関数は、事故を除いて、セットしません。
+
 =head2 Perl Functions by Category
 
+(カテゴリ別の Perl 関数)
+
+=begin original
+
 Here are Perl's functions (including things that look like
 functions, like some keywords and named operators)
 arranged by category.  Some functions appear in more
 than one place.
 
+=end original
+
+以下に、カテゴリ別の関数(キーワードや名前付き演算子のような、
+関数のように見えるものも含みます)を示します。
+複数の場所に現れる関数もあります。
+
 =over 4
 
 =item Functions for SCALARs or strings
@@ -290,9 +339,16 @@
 C<qx>, C<qw>, C<readline>, C<readpipe>, C<ref>, C<sub*>, C<sysopen>, C<tie>,
 C<tied>, C<uc>, C<ucfirst>, C<untie>, C<use>
 
+=begin original
+
 * - C<sub> was a keyword in perl4, but in perl5 it is an
 operator, which can be used in expressions.
 
+=end original
+
+* - C<sub> は perl4 ではキーワードですが、perl5 では演算子なので、
+式で使えます。
+
 =item Functions obsoleted in perl5
 
 C<dbmclose>, C<dbmopen>
@@ -5581,15 +5637,17 @@
 そのファイル名をコマンドとして解釈し、ファイルハンドルへの
 出力がパイプを通じて、そのコマンドへ入力されます。
 逆にファイル名の最後に C<'|'> を付けた場合には、
-同様にファイル名をコマンドと解釈し、そのコマンドの出力が
-パイプを通じて、ファイルハンドルから入力として
-読み込むことができるようになります。
-これに関する例については L<perlipc/"Using open() for IPC"> を参照してください。
-(C<open> を入出力両用にパイプすることは出来ませんが
+同様にファイル名をコマンドと解釈し、そのコマンドの出力がパイプを通じて、
+ファイルハンドルから入力として読み込むことができるようになります。
+これに関するさらなる例については L<perlipc/"Using open() for IPC"> を
+参照してください。
+(C<open> を入出力 I<両用> にパイプすることは出来ませんが
 代替案としては L<IPC::Open2>, L<IPC::Open3>,
 L<perlipc/"Bidirectional Communication with Another Process">
 を参照してください。)
 
+=begin original
+
 If MODE is C<'|-'>, the filename is interpreted as a
 command to which output is to be piped, and if MODE is
 C<'-|'>, the filename is interpreted as a command which pipes output to
@@ -5599,6 +5657,19 @@
 that pipes both in I<and> out, but see L<IPC::Open2>, L<IPC::Open3>,
 and L<perlipc/"Bidirectional Communication"> for alternatives.)
 
+=end original
+
+MODE が C<'|-'> の場合、ファイル名は出力がパイプされるコマンドとして
+解釈され、MODE が C<'-|'> の場合、ファイル名は出力がこちらに
+パイプされるコマンドとして解釈されます。
+2 引数(と 1 引数) の形式ではハイフン(C<'-'>)をコマンドの代わりに
+使えます。
+これに関するさらなる例については L<perlipc/"Using open() for IPC"> を
+参照してください。
+(C<open> を入出力 I<両用> にパイプすることは出来ませんが
+代替案としては L<IPC::Open2>, L<IPC::Open3>,
+L<perlipc/"Bidirectional Communication"> を参照してください。)
+
 =begin original
 
 In the 2-arguments (and 1-argument) form opening C<'-'> opens STDIN
@@ -5621,6 +5692,8 @@
 open は、成功時にはゼロ以外を返し、失敗時には未定義値を返します。
 パイプに関る C<open> のときには、返り値はサブプロセスの pid となります。
 
+=begin original
+
 If you're unfortunate enough to be running Perl on a system that
 distinguishes between text files and binary files (modern operating
 systems don't care), then you should check out L</binmode> for tips for
@@ -5629,6 +5702,19 @@
 Plan9, which delimit lines with a single character, and which encode that
 character in C as C<"\n">, do not need C<binmode>.  The rest need it.
 
+=end original
+
+不幸にしてテキストファイルとバイナリファイルを区別するシステムで
+Perl を動かす場合(最近の OS は区別しません)、これを扱うための
+TIPS について L</binmode> をチェックするべきです。
+C<binmode> が必要なシステムと不要なシステムを区別する鍵は
+テキストファイルの形式です。
+Unix, MacOS, Plan9 のような、行が 1 文字で分割され、その文字が
+C では C<"\n"> でエンコードされる場合、C<binmode> は不要です。
+そうでない場合は必要です。
+
+=begin original
+
 When opening a file, it's usually a bad idea to continue normal execution
 if the request failed, so C<open> is frequently used in connection with
 C<die>.  Even if C<die> won't do what you want (say, in a CGI script,
@@ -5637,8 +5723,26 @@
 the return value from opening a file.  The infrequent exception is when
 working with an unopened filehandle is actually what you want to do.
 
+=end original
+
+ファイルを開く時、開くのに失敗した時に通常の処理を続けるのは
+普通は悪い考えですので、C<open> はしばしば C<die> と結び付けられて
+使われます。
+望むものが C<die> がない場合(例えば、CGI スクリプト のように
+きれいにフォーマットされたエラーメッセージを作りたい場合
+(但しこの問題を助けるモジュールがあります))でも、
+ファイルを開いた時の帰り値を常にチェックするべきです。
+めったにない例外は、開いていないファイルハンドルを使うのが
+本当にやりたいことの場合です。
+
+=begin original
+
 Examples:
 
+=end original
+
+例:
+
     $ARTICLE = 100;
     open ARTICLE or die "Can't find article $ARTICLE: $!\n";
     while (<ARTICLE>) {...
@@ -6919,6 +7023,8 @@
 
 =item package 
 
+=begin original
+
 Declares the compilation unit as being in the given namespace.  The scope
 of the package declaration is from the declaration itself through the end
 of the enclosing block, file, or eval (the same as the C<my> operator).
@@ -6935,6 +7041,25 @@
 C<$::sail> is equivalent to C<$main::sail> (as well as to C<$main'sail>,
 still seen in older code).
 
+=end original
+
+与えられた名前空間でのコンパイル単位を宣言します。
+パッケージ宣言のスコープは、宣言自体から、閉じたブロック、ファイル、
+eval の終わりまでです(C<my> 演算子と同じです)。
+全てのさらなる修飾されてない動的識別子はこの名前空間になります。
+package 文は動的変数にのみ影響します -- C<local> で使ったものも
+含みます -- が、C<my> で作成されたレキシカル変数には I<影響しません>。
+典型的にはこれは C<require> や C<use> 演算子でインクルードされるファイルの
+最初に宣言されます。
+パッケージを複数の場所で切り替えることができます;
+これは単にコンパイラがこのブロックの残りに対してどのシンボルテーブルを
+使うかにのみ影響します。
+他のパッケージの変数やファイルハンドルは、識別子にパッケージ名と
+コロン 2 つをつけることで参照できます(C<$Package::Variable>)。
+パッケージ名が空文字列の場合、C<main> パッケージが仮定されます。
+つまり、C<$::sail> は C<$main::sail> と等価です(C<$main'sail> も
+古いコードではまだ見られます)。
+
 =begin original
 
 If NAMESPACE is omitted, then there is no current package, and all


perldocjp-cvs メーリングリストの案内
アーカイブの一覧に戻る