Here an implementation
Please note how ...
use strict; use warnings; my $section; my $hit; while (<DATA>) { my $start = /^ASDF \{\s*$/; #(2) my $end = /^\}\s*$/; if ($start .. $end) { $section .= $_; $hit = 1 if /foo_match/; } if ($end and $hit) { print $section; $section = $hit = ""; # reset (1) } } __DATA__ ASDF { tmp foo_match tmp } string2 { tmp } ASDF { tmp bar_match tmp }
NB:
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re^3: Matching a string in a parenthesized block (regex help)
by LanX
in thread Matching a string in a parenthesized block (regex help)
by maxamillionk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |