A new fatal error :
[p5sagit/p5-mst-13.2.git] / pod / perlsyn.pod
index efb8d8a..16bca2d 100644 (file)
@@ -33,13 +33,13 @@ as C<0>; when used as a string, it is treated 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, you'll
 be notified of an uninitialized value whenever you treat C<undef>
-as a string or a number.  Well, usually.  Boolean ("don't-care")
-contexts, such as:
+as a string or a number.  Well, usually.  Boolean contexts, such as:
 
     my $a;
     if ($a) {}
 
-are exempt from warnings.  Operators such as C<++>, C<-->, C<+=>,
+are exempt from warnings (because they care about truth rather than
+definedness).  Operators such as C<++>, C<-->, C<+=>,
 C<-=>, and C<.=>, that operate on undefined left values such as:
 
     my $a;
@@ -134,6 +134,13 @@ For C<last>, you have to be more elaborate:
            } while $x++ <= $z;
     }
 
+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.
+
 =head2 Compound statements
 
 In Perl, a sequence of statements that defines a scope is called a block.
@@ -183,8 +190,6 @@ refers to the innermost enclosing loop.  This may include dynamically
 looking back your call-stack at run time to find the LABEL.  Such
 desperate behavior triggers a warning if you use the C<use warnings>
 pragma or the B<-w> flag.
-Unlike a C<foreach> statement, a C<while> statement never implicitly
-localises any variables.
 
 If there is a C<continue> BLOCK, it is always executed just before the
 conditional is about to be evaluated again, just like the third part of a
@@ -319,7 +324,8 @@ is therefore visible only within the loop.  Otherwise, the variable is
 implicitly local to the loop and regains its former value upon exiting
 the loop.  If the variable was previously declared with C<my>, it uses
 that variable instead of the global one, but it's still localized to
-the loop.  
+the loop.  This implicit localisation occurs I<only> in a C<foreach>
+loop.
 
 The C<foreach> keyword is actually a synonym for the C<for> keyword, so
 you can use C<foreach> for readability or C<for> for brevity.  (Or because