use strict; use warnings; open OUTFILE, '>', 'delme.txt'; print OUTFILE <) { print "#" if m/^zone "\Q$targetdomain\E" {/ .. m/^}/; print; } #### zone "dontchangethisdomain.com" { type master; file "/somepath/to/dontchangethisdomain.com"; notify yes; } #zone "mydomain.com" { #type master; #file "/path/to/zone/mydomain.com"; #notify yes; #} zone "leavethisalonetoo.com" { type master; file "/other/path/to/leavethisalonetoo.com"; notify yes; }