From: abela@geneanet.org Date: Tue, 6 Mar 2001 09:40:36 +0000 (+0100) Subject: Clarify the description differentiating for and while; inspired by X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b78df5de4cbb361d400476487114def2ea80ea60;p=p5sagit%2Fp5-mst-13.2.git Clarify the description differentiating for and while; inspired by Subject: [ID 20010306.002] for/while difference in for definition Message-Id: <20010306084036.7BFD0D17F@little-roots.geneanet.org> p4raw-id: //depot/perl@9070 --- diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index e6b420e..aad4efd 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -263,7 +263,7 @@ available. Replace any occurrence of C by C. =head2 For Loops -Perl's C-style C loop works exactly like the corresponding C loop; +Perl's C-style C loop works like the corresponding C loop; that means that this: for ($i = 1; $i < 10; $i++) { @@ -279,8 +279,10 @@ is the same as this: $i++; } -(There is one minor difference: The first form implies a lexical scope -for variables declared with C in the initialization expression.) +There is one minor difference: if variables are declared with C +in the initialization section of the C, the lexical scope of +those variables is exactly the C loop (the body of the loop +and the control sections). Besides the normal array index looping, C can lend itself to many other interesting applications. Here's one that avoids the