Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^8: Bind zone file search

by ranceh (Initiate)
on Sep 26, 2012 at 19:33 UTC ( #995857=note: print w/ replies, xml ) Need Help??

in reply to Re^7: Bind zone file search
in thread Bind zone file search


Thanks much for all your help today.

Comment on Re^8: Bind zone file search
Replies are listed 'Best First'.
Re^9: Bind zone file search
by Kenosis (Priest) on Sep 26, 2012 at 19:49 UTC

    You're very welcome, ranceh!

      I've been testing this for the last little bit and I think I found something else.

      It wont match more than one entry per zone file. But there are more stanzas in each zone file.

      When I googled this, I see that I should change the trailing end of a regex to /m for multiple matches, but when I do, I don't get any. What am I missing?

        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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995857]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2015-11-25 10:36 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (673 votes), past polls