in reply to Re: Regular expression to list all files of type in folder
in thread Regular expression to list all files of type in folder
Thankfully this doesn't happen!!!
(I was ready to complain about rotten implementations...=)
Probably saved by one of these special magic behaviors of while
UPDATE:here it is
from perlop#I/O-Operators
The following lines are equivalent:while (defined($_ = <STDIN>)) { print; } while ($_ = <STDIN>) { print; } while (<STDIN>) { print; } for (;<STDIN>;) { print; } print while defined($_ = <STDIN>); print while ($_ = <STDIN>); print while <STDIN>;This also behaves similarly, but avoids $_ :
while (my $line = <STDIN>) { print $line }In these loop constructs, the assigned value (whether assignment is automatic or explicit) is then tested to see whether it is defined. The defined test avoids problems where line has a string value that would be treated as false by Perl, for example a "" or a "0" with no trailing newline. If you really mean for such values to terminate the loop, they should be tested for explicitly:
doesn't mention readdir but I think it's a similar case (and a documentation hole)
Cheers Rolf