If you always have your zone definitions separated with blank lines, but no blank lines in the zone blocks, the task is even easier - read and write the file in paragraph mode:
#!/usr/bin/perl -w -ni.bak -00
use strict;
BEGIN {
local $/ = "\n";
print "please enter the domain name: ";
use vars qw($targetdomain);
chomp ($targetdomain = <STDIN>);
}
print unless /^zone\s+"$targetdomain"/;
Call that script with the zone file as argument, e.g.
perl zonedel.pl /home/blackice/hello
It will create a backup of the file. For the switches after '#!/usr/bin/perl' see perlrun.
--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}
|