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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|