in reply to Grouping strings over a few line
Does grouping support multiple linesIt does if everything is in one string, and you use the /s modifier, so /./ can match a "\n" too.
If you read in the text one line at the time, you might reconsider using the .. or ... operator. That way, you can have a condition run over several lines in your data.
For example:
my $buffer; while(<>) { if(my $counter = (/^name\s.*\{/ ... /^name\s.*\{/)) { if($counter == 1) { # begin $buffer = ''; } $buffer .= $_; if($counter =~ /E/) { # end if($buffer =~ /name(.*)name/s) { print "Found: $1\n"; } redo; # retry with same line } } }
Unfortunately this will only find one match in your test data, because there's only two "name" strings — thus, only one range between them.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Grouping strings over a few line
by minixman (Beadle) on Oct 12, 2006 at 06:32 UTC | |
by bart (Canon) on Oct 13, 2006 at 20:11 UTC |