Update: added \n anchors and commented the regexp.#!/usr/bin/perl use common::sense; my $data = join('', <DATA>); $data =~ s{(^|\n)begin\n # begin at start of string or line (.*?\n)*? # lines to skip (non-greedy) end\n} # matching end {$1begin\nend\n}sx; print $data; __DATA__ a begin 1 a 2 end c begin c end a begin 1
In reply to Re: how to cut context between first "begin" and "end"?
by snoopy
in thread how to cut context between first "begin" and "end"?
by cxfcxf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |