#!/usr/bin/perl -w use strict; print " please enter the domain name: "; my $targetdomain = ; chomp $targetdomain; my $file = "/home/blackice/hello"; open my $fh, '<', $file or die "Can't read '$file': $!\n"; my @array = <$fh>; close $fh or die "Can't close file '$file' properly: $!\n"; my $comment = 0; my $block = 0; for (@array) { if (/^zone\s+"$targetdomain"/) { $comment++; $block += () = /(\{)/g; print $out '// '.$_; next; } if($comment) { $block += () = /(\{)/g; s!^!// ! if $comment or $block; $block -= () = /(\})/g; $comment = 0 unless $block; } } open $fh, '>', $file or die "Can't write '$file': $!\n"; print $fh @array; close $fh or die "Can't close file '$file' properly: $!\n";