thanks mwa and thanks for you tips also
iam now having a problem and i think it's stupidness to have such one
i posts some posts about how to comment zones in the zone file and i got a wonderful answers and a good code especially from shmem
by the way here is the code shmem wrote
#!/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 $_;
}
and it works very well and i understand the way of that script works and it was agood idea
but i want to add some feature to this script i want to add the date at the top of the zone when that zone was commented on
i have tried to make some tries ,, i have creates
my $date = `date -u "+%m/%d/%Y %H:%M:%S"`;
this is a date string that i can print in the script and i tried to print it here
print "date";
print $out $_;
also i have tried to print it before this line
print $out '// '.$_; next;
but it failed ,, i also have tried to print it in some other places and it also fails
so can you help me of how to think about that
thanks
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.