firewall00 has asked for the wisdom of the Perl Monks concerning the following question:
hello all
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#!/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 $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deleting lines from named.conf file
by toolic (Bishop) on Nov 10, 2007 at 02:29 UTC | |
by firewall00 (Acolyte) on Nov 10, 2007 at 03:42 UTC | |
|
Re: Deleting lines from named.conf file
by eric256 (Parson) on Nov 09, 2007 at 23:31 UTC | |
by firewall00 (Acolyte) on Nov 10, 2007 at 00:37 UTC | |
by firewall00 (Acolyte) on Nov 10, 2007 at 01:29 UTC | |
|
Re: Deleting lines from named.conf file
by shmem (Chancellor) on Nov 10, 2007 at 14:27 UTC | |
by firewall00 (Acolyte) on Nov 10, 2007 at 19:04 UTC | |
by shmem (Chancellor) on Nov 10, 2007 at 20:07 UTC | |
by chromatic (Archbishop) on Nov 10, 2007 at 22:38 UTC | |
by shmem (Chancellor) on Nov 10, 2007 at 22:44 UTC | |
by firewall00 (Acolyte) on Nov 10, 2007 at 21:38 UTC | |
by shmem (Chancellor) on Nov 10, 2007 at 21:52 UTC | |
|