Can anybody show with some examples the exact difference between .. and ... operator?
From the perlop man page:
If you don’t want it to test the right operand until the next
evaluation, as in sed, just use three dots (“…”) instead of two.
But what exactly this mean? I don’t understand the perlop’s example:
@lines = (" - Foo",
"01 - Bar",
"1 - Baz",
" - Quux"
);
foreach (@lines) {
if (/0/ .. /1/) {
print "$_\n";
}
}
with ... will print the Baz – but why? More precisely, why is Baz not printed with two dots and only with ...?
«
...» doesn’t do a flop check immediately after a true flip check.With «
..»," - Foo"/0/returns false...returns false."01 - Bar"/0/returns true. Flip!/1/returns true. Flop! ⇐..returns true (since the first check was true)."1 - Baz"/0/returns false...returns false." - Quux"/0/returns false...returns false.With «
...»," - Foo"/0/returns false....returns false."01 - Bar"/0/returns true. Flip!...returns true."1 - Baz"/1/returns true. Flop!...returns true." - Quux"/0/returns false....returns false.