in reply to Re^3: Perl script to comment out lines in named.con file
in thread Perl script to comment out lines in named.conf file
#!/usr/bin/perl -w use strict; print " please enter the domain name: "; my $targetdomain = <STDIN>; chomp $targetdomain; my $file = "/home/blackice/hello"; open HAN,$file || die "error opening file: $!"; my $comment = 0; my $block = 0; while (<HAN>) { /^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; }
|
|---|