Here's an example (taken from a rubycentral.com article) where you print out only certain lines from a file:
file = File.open("ordinal")
while file.gets
print if ($_ =~ /third/) .. ($_ =~ /fifth/)
end
This assumes that you have a file with the following contents:
first
second
third
fourth
fifth
sixth
The program will only print out:
third
fourth
fifth
The idea is that it the value is true until the left-hand event happens, and then stays true until the right-hand event happens. If used properly this can be a nice piece of syntactic sugar, but you need to be careful to make things readable.
Edit: fixed code that rampion found objectionable.
Reference: