argra****@users*****
argra****@users*****
2007年 11月 14日 (水) 02:55:00 JST
Index: docs/perl/5.8.8/perldata.pod diff -u docs/perl/5.8.8/perldata.pod:1.2 docs/perl/5.8.8/perldata.pod:1.3 --- docs/perl/5.8.8/perldata.pod:1.2 Wed Aug 29 18:18:53 2007 +++ docs/perl/5.8.8/perldata.pod Wed Nov 14 02:55:00 2007 @@ -1583,11 +1583,9 @@ =end original -A slice accesses several elements of a list, an array, or a hash -simultaneously using a list of subscripts. It's more convenient -than writing out the individual elements as a list of separate -scalar values. -(TBT) +スライスは、添え字のリストを使ってリスト、配列、ハッシュの複数の要素に +同時にアクセスします。 +これはそれぞれの要素を個々のスカラ値のリストとして扱うより便利です。 ($him, $her) = @folks[0,-1]; # array slice @them = @folks[0 .. 3]; # array slice Index: docs/perl/5.8.8/perlsyn.pod diff -u docs/perl/5.8.8/perlsyn.pod:1.2 docs/perl/5.8.8/perlsyn.pod:1.3 --- docs/perl/5.8.8/perlsyn.pod:1.2 Sun Sep 9 03:35:00 2007 +++ docs/perl/5.8.8/perlsyn.pod Wed Nov 14 02:55:00 2007 @@ -93,10 +93,11 @@ =end original -The only things you need to declare in Perl are report formats and -subroutines (and sometimes not even subroutines). A variable holds -the undefined value (C<undef>) until it has been assigned a defined -value, which is anything other than C<undef>. When used as a number, +Perl で宣言が必要なものはレポートフォーマットとサブルーチンだけです +(サブルーチンすら宣言が不要な場合もあります)。 +変数は、C<undef> 以外の定義された値を代入されるまでは未定義値(C<undef>)と +なります。 +When used as a number, C<undef> is treated as C<0>; when used as a string, it is treated as the empty string, C<"">; and when used as a reference that isn't being assigned to, it is treated as an error. If you enable warnings, @@ -270,12 +271,12 @@ =end original -The number 0, the strings C<'0'> and C<''>, the empty list C<()>, and -C<undef> are all false in a boolean context. All other values are true. -Negation of a true value by C<!> or C<not> returns a special false value. -When evaluated as a string it is treated as C<''>, but as a number, it -is treated as 0. -(TBT) +数値 0, 文字列 C<'0'> と C<''>, 空リスト C<()>, C<undef> は全て真偽値 +コンテキストでは偽となります。 +その他の全ての値は真です。 +真の値を C<!> や C<not> で否定すると、特殊な偽の値を返します。 +これを文字列として評価すると C<''> として扱われますが、数値として評価すると +0 として扱われます。 =head2 Statement Modifiers X<statement modifier> X<modifier> X<if> X<unless> X<while> @@ -306,9 +307,8 @@ =end original -The C<EXPR> following the modifier is referred to as the "condition". -Its truth or falsehood determines how the modifier will behave. -(TBT) +修飾子に引き続く C<EXPR> は「条件」として参照されます。 +その真偽値が修飾子の振る舞いを決定します。 =begin original @@ -318,10 +318,9 @@ =end original -C<if> executes the statement once I<if> and only if the condition is -true. C<unless> is the opposite, it executes the statement I<unless> -the condition is true (i.e., if the condition is false). -(TBT) +C<if> は I<もし> 条件が真の場合にのみ文を実行します。 +C<unless> は逆で、条件が真 I<でない限り> (つまり、条件が偽なら) 文を +実行します。 print "Basset hounds got long ears" if length $ear >= 10; go_outside() and play() unless $is_raining; @@ -333,7 +332,7 @@ =end original -C<foreach> 修飾子はイテレーターです。 +C<foreach> 修飾子は反復子です。 LIST の値それぞれ毎に文を実行します(実行中は C<$_> がそれぞれの値の エイリアスとなります)。 @@ -347,10 +346,9 @@ =end original -C<while> repeats the statement I<while> the condition is true. -C<until> does the opposite, it repeats the statement I<until> the -condition is true (or while the condition is false): -(TBT) +C<while> は条件が真 I<の間> 文を繰り返します。 +C<until> は逆で、条件が真 I<になるまで> (つまり条件が偽の間) 文を +繰り返します: # Both of these count from 0 to 10. print $i++ while $i <= 10; @@ -429,14 +427,14 @@ =end original -B<NOTE:> The behaviour of a C<my> statement modified with a statement -modifier conditional or loop construct (e.g. C<my $x if ...>) is -B<undefined>. The value of the C<my> variable may be C<undef>, any -previously assigned value, or possibly anything else. Don't rely on -it. Future versions of perl might do something different from the -version of perl you try it out on. Here be dragons. +B<注意:> (C<my $x if ...> のような) 条件構造やループ構造で修飾された +C<my> 文の振る舞いは B<未定義> です。 +C<my> 変数の値は C<undef> かも知れませんし、以前に代入された値かも +知れませんし、その他の如何なる値の可能性もあります。 +この値に依存してはいけません。 +perl の将来のバージョンでは現在のバージョンとは何か違うかも知れません。 +ここには厄介なものがいます。 X<my> -(TBT) =head2 Compound Statements X<statement, compound> X<block> X<bracket, curly> X<curly bracket> X<brace> @@ -771,12 +769,9 @@ =end original 小さな違いが一つあります: -if variables are declared with C<my> -in the initialization section of the C<for>, the lexical scope of -those variables is exactly the C<for> loop (the body of the loop -and the control sections). +C<for> の初期化部で C<my> を使って変数が宣言された場合、この変数のレキシカル +スコープは C<for> ループ (ループ本体と制御部) と完全に同じです。 X<my> -(TBT) =begin original @@ -878,12 +873,11 @@ LIST の要素のいずれかが左辺値であった場合、ループの中で VAR を変更することにより、対応する値を変更することができます。 -Conversely, if any element of LIST is NOT an -lvalue, any attempt to modify that element will fail. +逆に、LIST の要素のうち 1 つでも左辺値でない場合は、この要素を +修正しようとしても失敗します。 言い換えると、C<foreach> ループの帰納変数がループの対象となっている リスト中の個々のアイテムに対するエイリアスになっているからです。 X<alias> -(TBT) =begin original Index: docs/perl/5.8.8/perltie.pod diff -u docs/perl/5.8.8/perltie.pod:1.2 docs/perl/5.8.8/perltie.pod:1.3 --- docs/perl/5.8.8/perltie.pod:1.2 Sun Sep 9 03:35:00 2007 +++ docs/perl/5.8.8/perltie.pod Wed Nov 14 02:55:00 2007 @@ -987,7 +987,7 @@ コンストラクタである TIEHASH、キーと値のペアにアクセスする FETCH と STORE、 キーがハッシュにあるかどうかを報告する EXISTS、キーを削除するための DELETE、 すべてのキーと値のペアを削除することによりハッシュを空にする CLEAR、 -すべてのキーをイテレートするための関数 keys() と each() を実装する +すべてのキーを反復するための関数 keys() と each() を実装する FIRSTKEY と NEXTKEY、 SCALAR is triggered when the tied hash is evaluated in scalar context. UNTIE is called when C<untie> happens, and @@ -1480,7 +1480,7 @@ =end original このメソッドは keys() や each() を呼び出すのと同様に、ハッシュを通じた -イテレートをユーザーが行おうとするときに呼び出されます。 +反復をユーザーが行おうとするときに呼び出されます。 sub FIRSTKEY { carp &whowasi if $DEBUG; @@ -1501,9 +1501,9 @@ =end original -このメソッドは keys() または each() イテレーションの間に呼び出されます。 +このメソッドは keys() または each() 反復の間に呼び出されます。 二番目の引数として、最後にアクセスしたキーをとります。 -これは、あなたが順番に取り出すとか、二度以上イテレータを呼び出したり、 +これは、あなたが順番に取り出すとか、二度以上反復子を呼び出したり、 あるいは実際にはハッシュのどこにも格納されていないものであるときに 便利です。