in reply to Re^10: Bind zone file search
in thread Bind zone file search
The m modifier will not help here. I (incorrectly) assumed that there was only one zone stanza per file. Processing multiple zone stanzas requires globally matching and preventing part of the regex from being 'greedy.' Try the following line:
$hash{$1} = $2 while $data =~ /zone\s+"([^"]+)".+?masters\s+{[\s#\/]*([a-zA-Z0-9.- +]+)[\s#\/;]*}/sg;
You'll note that: while has replaced if, there's a ? right after the + preceding masters, and the globally modifier is used.
while is used to process all matches; the ? prevents the regex from being 'greedy,' so it doesn't start the match at the beginning of a zone stanza and end the match with the last stanza.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^12: Bind zone file search
by ranceh (Novice) on Sep 27, 2012 at 13:53 UTC | |
by Kenosis (Priest) on Sep 27, 2012 at 15:59 UTC | |
by ranceh (Novice) on Sep 27, 2012 at 16:30 UTC | |
by Kenosis (Priest) on Sep 27, 2012 at 17:03 UTC |
In Section
Seekers of Perl Wisdom