develooper Front page | perl.perl5.porters | Postings from October 2003

[PATCH] perlsyn.pod Revision - Resend

Thread Next
From:
Shlomi Fish
Date:
October 2, 2003 10:38
Subject:
[PATCH] perlsyn.pod Revision - Resend
Message ID:
Pine.LNX.4.56.0310022035510.17366@vipe.technion.ac.il
--- original/perlsyn.pod	2003-10-02 20:26:09.000000000 +0300
+++ revised/perlsyn.pod	2003-10-02 20:33:06.000000000 +0300
@@ -29,8 +29,10 @@
 =head2 Declarations
 
 The only things you need to declare in Perl are report formats
-and subroutines--and even undefined subroutines can be handled
-through AUTOLOAD.  A variable holds the undefined value (C<undef>)
+and subroutines.  (Undefined subroutines can be handled
+through the AUTOLOAD feature as documented in L<perlsub>)  
+ 
+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, C<undef> is treated
 as C<0>; when used as a string, it is treated the empty string,
@@ -110,12 +112,18 @@
     until EXPR
     foreach EXPR
 
-The C<if> and C<unless> modifiers have the expected semantics,
-presuming you're a speaker of English.  The C<foreach> modifier is an
-iterator:  For each value in EXPR, it aliases C<$_> to the value and
-executes the statement.  The C<while> and C<until> modifiers have the
-usual "C<while> loop" semantics (conditional evaluated first), except
-when applied to a C<do>-BLOCK (or to the deprecated C<do>-SUBROUTINE
+C<if> executes a the statement once if C<EXPR> evaluated to a true value.
+C<unless> executes the statement once if the condition (C<EXPR>) did not.
+A false value is C<undef>, 0, the empty string, and the floating number 
+0.0.  A true value is everything else. Normally, you'll wish to use 
+a mechanism that explicitly return a true or false value as a 
+boolean expression there.
+
+C<while> and C<until> repeat the same block of statements while or 
+until the condition is true.  (I.e.: C<until> iterates while it is 
+false) The C<while> and C<until> modifiers have the usual 
+"C<while> loop"  semantics (conditional evaluated first), except 
+when applied to a C<do>-BLOCK (or to the deprecated C<do>-SUBROUTINE 
 statement), in which case the block executes once before the
 conditional is evaluated.  This is so that you can write loops like:
 
@@ -151,6 +159,10 @@
 it.  Future versions of perl might do something different from the
 version of perl you try it out on.  Here be dragons.
 
+Finally, the C<foreach> modifier is an iterator: For each value 
+in EXPR, it aliases the special "default" variable C<$_> to the 
+value and executes the statement.
+
 =head2 Compound Statements
 
 In Perl, a sequence of statements that defines a scope is called a block.
@@ -565,7 +577,8 @@
 The C<goto>-LABEL form finds the statement labeled with LABEL and resumes
 execution there.  It may not be used to go into any construct that
 requires initialization, such as a subroutine or a C<foreach> loop.  It
-also can't be used to go into a construct that is optimized away.  It
+also can't be used to go into a construct that is optimized away at
+the compilation stage, like an C<if (0) { ... }> block.  It
 can be used to go almost anywhere else within the dynamic scope,
 including out of subroutines, but it's usually better to use some other
 construct such as C<last> or C<die>.  The author of Perl has never felt the

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About