dear fellow monks,
why does ...
opendir(D, "test"); while ( $file = readdir(D) ) { print "$file is "; print ($file ? "true" : "false"); print "\n"; }
... work correctly, even for a filename like "0" that evaluates to false in boolean context? (see here for full code + output)
This seems to be an extreme case of "do-what-i-mean". I find it a little scary, because I don't know how it does what I mean ;-)
p.s.
I hit on this while doing research for my talk
on php an perl at this years german perl workshop. the
php counterpart looks appalingly complicated:
# this is php, not perl! $d = opendir('test); while (false !== ($file = readdir($d))) { print "$file is "; print ($file ? "true" : "false"); print "\n"; }
see also the php documentation.
-- Brigitte 'I never met a chocolate I didnt like' Jellinek http://www.horus.com/~bjelli/ http://perlwelt.horus.at
In reply to readdir and while - magic? by bjelli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |