You'll find information about "..." in perlop:
In scalar context, ".." returns a boolean value. The operator is bistable, like a flip-flop...
(I doubt I can explain this particular construct in any sort of coherent manner, so I'll leave that to BUU.)
| [reply] [d/l] |
Basically the flip-flop operator has two sides, a left hand and a right hand. The left hand side is evaluated first, and it it returns false, the entire construct returns false. However, when the left side returns true, the entire construct returns true and *keeps* returning true untill the right hand side also returns true, then the entire thing starts to return false again. Heres an example in code:
for(0..10)
{
if(/2/../5/)
{
print;
}
}
On the first iteration, it checks /2/ against $_, which contains 0, so it returns false and nothing is printed. On the second iteration, same thing, except $_ contains 1. On the third iteration however, $_ contains 2 so /2/ matches and the construct returns true and it prints. It keeps printing numbers untill $_ matches /5/.
The more verbose form of this code would look like:
my $flag;
for(0..10)
{
if(/2/)
{
$flag = 1;
}
print if $flag;
if(/5/)
{
$flag = 0;
}
}
Note that the check to set $flag to 0 is *after* the print statement. This is because the construct returns true the first time the right hand side also returns true. It of course returns false after that.
For the rest of my original code, as hofmator explains below, (/foo/../bar/) returns a string, not just a boolean value, and that string has "E0" appended to it when the right hand returns true (thus meaning it's the last value the flip-flop will return true for). | [reply] [d/l] [select] |