#!/usr/bin/perl -w use strict; print " please enter the domain name: "; my $targetdomain = ; chomp $targetdomain; my $file = "/home/blackice/hello"; open HAN,$file || die "error opening file: $!"; my $comment = 0; my $block = 0; while () { /^zone\s+"$targetdomain"/ and $comment++; if($comment) { $block += () = /(\{)/g; # add the number of { matches to $block s!^!// ! if $comment && $block; $block -= () = /(\})/g; # substract the number of } matches $comment = 0 unless $block; } print; }