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

[perl #21785] [PATCH] clarify readdir in for conditional

Thread Next
From:
Casey West
Date:
April 24, 2003 17:03
Subject:
[perl #21785] [PATCH] clarify readdir in for conditional
Message ID:
20030425000720.GI34510@geeknest.com
Ticket URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21785

The original requestor's problem has been noted in the documentation,
but Ronald brings an excellent point about a for loop.  This patch
clarifies what for does to readdir in the conditional.

  Casey West

-- 
Shooting yourself in the foot with Pascal 
The compiler won't let you shoot yourself in the foot. 

--- perl-current.orig/pod/perlsyn.pod   Fri Mar 21 16:54:26 2003
+++ perl-current/pod/perlsyn.pod        Thu Apr 24 19:57:53 2003
@@ -315,6 +315,14 @@
        # do something
     }
 
+When using C<readdir> (or the operator form, C<< <EXPR> >>) as the
+conditional of a C<for> loop is shorthand for the following.  This
+behaviour is the same as a C<while> loop conditional.
+
+    for ( prompt(); defined( $_ = <STDIN> ); prompt() ) {
+        # do something
+    }
+
 =head2 Foreach Loops
 
 The C<foreach> loop iterates over a normal list value and sets 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