"The condition evaluates false until $left evaluates true. Then the $left condition is ignored, and the condition continues to evaluate true until $right evaluates true, at which point the condition evaluates false, and it goes back to check $left."
Not very precise, and a bit misleading. In the case of "if (2..4)", $left is 2, and $right is 4, both of them always evalutes to true. I know that later you explained that, they were compared to $., and that was right. I suggest you reword this part to make it correct, and agree with other parts of your post.
I think it would be useful to give this example, to explain an interesting situation, which people might run into:
use strict;
use warnings;
open(FILE, "<", "test.dat");
while (<FILE>)
{
print if 2 .. 4;
}
print "=====\n";
open(FILE, "<", "test.dat");
while (<FILE>)
{
print if 2 .. 4;
}
====input====
one
two
three
four
five
====output====
two
three
four
=====
This reminds people the fact that $. is not reset when a file is reopened when no explicit close() called in between.
-
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.
|