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

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

Thread Next
Casey West
April 24, 2003 17:03
[perl #21785] [PATCH] clarify readdir in for conditional
Message ID:
Ticket URL:

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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About