15と17の間にある連続したピリオドがポイントです。
この演算子は、
for my $i in (1..10) {
のように書くと、1から10までという範囲を表すものになりますが、
if (15..17) {
のようにした場合、
In scalar context, ".." returns a boolean value. The operator is
bistable, like a flip-flop, and emulates the line-range (comma) operator
of sed, awk, and various editors. Each ".." operator maintains its own
boolean state. It is false as long as its left operand is false. Once
the left operand is true, the range operator stays true until the right
operand is true, *AFTER* which the range operator becomes false again.
It doesn't become false till the next time the range operator is
evaluated. It can test the right operand and become false on the same
evaluation it became true (as in awk), but it still returns true once.
If you don't want it to test the right operand till the next evaluation,
as in sed, just use three dots ("...") instead of two. In all other
regards, "..." behaves just like ".." does.
The right operand is not evaluated while the operator is in the "false"
state, and the left operand is not evaluated while the operator is in
the "true" state. The precedence is a little lower than || and &&. The
value returned is either the empty string for false, or a sequence
number (beginning with 1) for true. The sequence number is reset for
each range encountered. The final sequence number in a range has the
string "E0" appended to it, which doesn't affect its numeric value, but
gives you something to search for if you want to exclude the endpoint.
You can exclude the beginning point by waiting for the sequence number
to be greater than 1.
If either operand of scalar ".." is a constant expression, that operand
is considered true if it is equal ("==") to the current input line
number (the $. variable).
ということになります。
#すみませんが日本語訳は自分で探してください
#perlop.pod とかで探せば見つかるかも
で結局どういうことかというと、
$. が 15から17の間だけこのifの条件は真になります。
$. は入力行の行数ですから、結果的に15行目から17行までを
出力するということになります。
と。日本語訳ありました
perlop - Perl の演算子と優先順位
http://perldoc.jp/docs/perl/5.8.8/perlop.pod
の、
Range Operators operator, range range .. ...
という見出しからちょっと下がった辺りです。
お礼
ありがとうございます!