in reply to Perl script to comment out lines in named.conf file
Good start, but are all your zone definitions that uniform?
You might have some that read
zone "10.in-addr.arpa" { type forward; forwarders { 10.1.2.3; 10.1.2.4; 10.1.2.5; }; };
There are, as always, many ways to do it - one:
my $comment = 0; my $block = 0; while (<HAN>) { /^zone\s+"$targetdomain"/ and $comment++; if($comment) { $block += () = /(\{)/g; # add the number of { matches t +o $block s!^!// ! if $comment && $block; $block -= () = /(\})/g; # substract the number of } mat +ches $comment = 0 unless $block; } print; }
That will work only if the opening curly after a zone declaration is on the same line.
BTW, you need a semicolon after every closing curly in your zone file ( }; ).
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In Section
Seekers of Perl Wisdom