in reply to Re: Searching for and removing multi-line file entries
in thread Searching for and removing multi-line file entries
This only removes one server entry, but it will be easy enough to throw a foreach loop around it.use strict; use warnings; # use re "debug"; my $file = shift @ARGV || die "No file name given!\n"; my $server = shift @ARGV; my $output = shift @ARGV; open(IN, "$file") or die "Unable to open file\n"; undef $/; my $content = <IN>; $content =~ s/ ^\[server(\d)\] .*? servername\s=\s$server .*? \[server +\d\]$/\[server$1\]/msxi close(IN); open(OUT, ">$output"); print OUT $content; close(OUT);
|
|---|