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 = ; $content =~ s/ ^\[server(\d)\] .*? servername\s=\s$server .*? \[server\d\]$/\[server$1\]/msxi close(IN); open(OUT, ">$output"); print OUT $content; close(OUT);