http://www.perlmonks.org?node_id=864153


in reply to Regular expression...

Here is one way to do it.

$string =' some another lines =begin some lines some lines =end some another lines...'; while ($string =~ /(?:(?:^|\n)=begin)((?:(?!\n=end).)*)\n=end/gs){ print "$1\n"; } output: ======= some lines some lines
Updated: included '\n' before =end.

Prasad