in reply to Matching across multiple lines
You can't match across multiple lines here, because the while is reading the file one line at a time, so your regexp never sees more than one line.
You either need to slurp the whole file in at once, or try a different approach. Personally I prefer to use the .. operator for this type of processing...
while(<>) { if(/Start/ .. /End/) { print } }
Or, slurp in the whole file...
{ local $/; my $input = <>; if(/ Start(.*)? End/sg) { print $1 } }
| We're not surrounded, we're in a target-rich environment! |
|---|
|
|---|