my $line; while ($line = ) { my $string; # check for start of virtual host block if ( $line =~ /^\s*\; $string = $string . $line; } until $line =~ /^s*\<\/VirtualHost\>/; # Find the server name $string =~ /ServerName\s+(.*)\s/; # Ignore it if necessary...you can add a number of checks here # including multple servers that you want to ignore. if ( $1 ne "my.domain.here" ) { print $string; } } else { # if not a virtual server line, just pass it through. print $line; } }