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 @fileContent = <HAN>; close(HAN); for( my $i = 0; $i < @fileContent; $i++ ){ if( $fileContent[$i] =~ m/^zone\s+"$targetdomain"/ ){ $fileContent[$i] =~ s/\n/\n#/g; } } open HAN, ">$file"; print HAN @fileContent; close(HAN);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Perl script to comment out lines in named.con file
by GrandFather (Saint) on Oct 05, 2007 at 04:31 UTC |