in reply to Re^5: FEAR OF PERL
in thread FEAR OF PERL
#!/usr/bin/perl -w use strict; print " please enter the domain name: "; my $targetdomain = <STDIN>; chomp $targetdomain; my $file = "/home/blackice/hello"; rename $file, "$file.bak" or die "Can't rename file '$file': $!\n"; open my $in, '<', "$file.bak" or die "Can't read file '$file': $!\n"; open my $out, '>', $file or die "Can't write file '$file': $!\n"; my $comment = 0; my $block = 0; while(<$in>) { 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; } print $out $_; }
print "date"; print $out $_;
thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: FEAR OF PERL
by firewall00 (Acolyte) on Oct 15, 2007 at 03:27 UTC | |
by TGI (Parson) on Oct 15, 2007 at 17:13 UTC |