in reply to Re^9: Deleting lines from named.conf file
in thread Deleting lines from named.conf file

i have tried to eliminate the blank line that created so i but this line before the print line
next if /^\s*$/;

but this suppress any new line in the whole file
i think i need to provide something like unless /\s/; after printing the line for this zone only

Replies are listed 'Best First'.
Re^11: Deleting lines from named.conf file
by shmem (Chancellor) on Nov 11, 2007 at 11:07 UTC
    If you always have your zone definitions separated with blank lines, but no blank lines in the zone blocks, the task is even easier - read and write the file in paragraph mode:
    #!/usr/bin/perl -w -ni.bak -00 use strict; BEGIN { local $/ = "\n"; print "please enter the domain name: "; use vars qw($targetdomain); chomp ($targetdomain = <STDIN>); } print unless /^zone\s+"$targetdomain"/;
    Call that script with the zone file as argument, e.g.
    perl zonedel.pl /home/blackice/hello

    It will create a backup of the file. For the switches after '#!/usr/bin/perl' see perlrun.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      thanks mr shmem you were surly right but i was having some mistakes . thanks for your great support

      Really thanks for you further assistance


      but i used what you have said "paragraph mode" but there is also still a 2 blank lines between the zone assume that i have deleted a zone in the middle of 2 zones
      the out is still just like that
      zone "foo.com" { type xxxxx path xxxxx info xxxxx }; zone "blah.com" { type xxxxx path xxxxx info xxxxx }; zone "bar.com" { type xxxxx path xxxxx info xxxxx };
      after running zonedel.pl with your new optimization
      zone "foo.com" { type xxxxx path xxxxx info xxxxx }; #2 blanks still created # zone "bar.com" { type xxxxx path xxxxx info xxxxx };

      i have read perlrun and i didnot find any switch that i can enable to eliminate the the blank lines created
      what do you think about providing a line that makes a shifted up move after delete zone
      or after deletion do
      s/\n//;
      to eliminate the created blank line so i will always have a one blank line between the two zones
      and thanks again for your further support