#! perl -w use strict; $/ = undef; my $data = ; my @fields = split /(?<=\n)(<\/?VirtualHost.*>[ \t]*\n)/, $data; printf "sanity check before: %d fields\n", scalar @fields; for (my $i = $#fields-2; $i >= 0; --$i) { if ($fields[$i] =~ m([ \t]*\n) && $fields[$i+1] =~ m(ServerNameTwo) && $fields[$i+2] =~ m(<\/VirtualHost>[ \t]*\n) ) { splice @fields, $i, 3; } } printf "sanity check after: %d fields\n", scalar @fields; print join '', @fields; __END__ ### mock httpd.conf file used as test data ### Hello everyone, This is my first post. I've been search through previous posts and several Perl books but I haven't been able to find a solution to my problem. I'm quite new to Perl by the way. Here's the problem. I need to parse a httpd.conf file and remove a VirtualHost block. It looks like this: ServerNameOne www.domain.com ... I need to be able to parse the file, find the appropriate ServerName, and then remove that entire VHost block. I'm stuck on this one. If anyone can help I would greatly appreciate it. Thanks, Brendon ServerNameTwo www.domain.com ... qwertzuiop... qwertzuiop... ServerNameThree www.domain.com ... qwertzuiop... qwertzuiop... qwertzuiop...