What is the scalar “..” operator typical usage? Is it only selecting blocks of text?
Interesting example by myself:
sub get_next {
print scalar($$..!$$), "\n";
}
get_next for 1 .. 5; # prints numbers from 1 to 5
get_next for 1 .. 5; # prints numbers from 6 to 10
People hardly seem to know about it based on questions here, but, yes, I’d say typical usage is selecting blocks of text, either with
or
The latter is syntactic sugar for checking against the input line-number (
$.)which suggests the weird-looking
The above program’s output is
If you have some sort of bracketing condition, test for it in subs: