hello all


first i would thank this great forum which helped me many times
by the way i had another thread before about commenting zone in the named.conf file ,, and now i want to delete lines instead of commenting only
first i have tried many times ,, i have stored the file in array and then try to loop throw this array to delete specific lines but this failed .
so i reuse the code i have used to make the commenting
#!/usr/bin/perl -w use strict; print " please enter the domain name: "; my $targetdomain = <STDIN>; my $susdate = `date -u "+%m/%d/%Y %H:%M"`; my $char = "This Domain is Suspended at "; chomp $targetdomain; my $file = "/home/adam/Desktop/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"/) { s// /; $comment++; $block += () = /(\{)/g; } if($comment) { $block += () = /(\{)/g; $block -= () = /(\})/g; $comment = 0 unless $block; } print $out $_; }
i want to delete all the lines between the two open brackets so i provide the block to count the open brackets and also closed brackets
could any one tell me how can i think about that and i will be thankful

In reply to Deleting lines from named.conf file by firewall00

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.