:utf8 works only with perlio.
[p5sagit/p5-mst-13.2.git] / pod / perlsyn.pod
index e6b420e..9d0c920 100644 (file)
@@ -263,7 +263,7 @@ available.   Replace any occurrence of C<if BLOCK> by C<if (do BLOCK)>.
 
 =head2 For Loops
 
-Perl's C-style C<for> loop works exactly like the corresponding C<while> loop;
+Perl's C-style C<for> loop works like the corresponding C<while> 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<my> in the initialization expression.)
+There is one minor difference: 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).
 
 Besides the normal array index looping, C<for> can lend itself
 to many other interesting applications.  Here's one that avoids the
@@ -391,8 +393,18 @@ structures.
     }
 
 There is no official C<switch> statement in Perl, because there are
-already several ways to write the equivalent.  In addition to the
-above, you could write
+already several ways to write the equivalent.
+
+However, starting from Perl 5.8 to get switch and case one can use
+the Switch extension and say:
+
+       use Switch;
+
+after which one has switch and case.  It is not as fast as it could be
+because it's not really part of the language (it's done using source
+filters) but it is available, and it's very flexible.
+
+In addition to the above BLOCK construct, you could write
 
     SWITCH: {
        $abc = 1, last SWITCH  if /^abc/;