in reply to regex large named.conf parsing

If you don't want to keep the original file open, why don't you simply copy it and read line by line with while (<>)? I think 20Meg on Harddisk is less expensive than 20Meg of Memory.

However. I think you can shorten your re:

You have: /(zone\s+"$domain"\s+\{\r?\n(.*?)\r?\n(.*?)\r?\n(\s+)?\};(\r +?\n)+)/ Won't this do: /(zone\s+"$domain"\s+\{[^}]+\};[\r\n]+)/o
Since you don't need all the elements found in $2, $3..., why store them?

Should you need them, you can extract them later, when you found a match for the domain.

You should also ad o to your regexp in order to insert $domain's content just once into your re.