#!/usr/bin/perl -w use strict; print " please enter the domain name: "; my $targetdomain = ; chomp $targetdomain; my $file = "/home/adam/Desktop/hello"; open HAN,$file || die "error opening file: $!"; my @lines = ; close(HAN); foreach my $x ( 0 .. $#lines ){ if( $lines [$x] =~ m/^zone\s+"$targetdomain"/ ){ for my $n (0 .. 7) { if( $lines[$x+$n] =~ m/^\s};/ ){ last ; } $lines[$x+$n] = "//" . $lines[$x+$n]; } } } open HAN, ">$file"; print HAN $_ for @lines; close(HAN);