in reply to match and edit block of text

You don't say how you want to match it. Anyhow, this is the basics of the replacement: Code:
{ local $^I = ".bak"; local *ARGV; @ARGV = "/path/to/httpd.conf"; while(<>) { s/^(?=.)/# /; # simple substitution print; } }
You'll probably have to make the rules for the update more complex. Here's one way to match a <Directory> block. Put the following code block inside the while(<>){ ... } block:
if((my($dir) = /^<Directory\s+(.*)>/i) ... /<\/Directory>/i) { if(defined $dir) { # first line in the block for ($dir) { s/^"//; s/"$//; # remove quotes $icons = m(/icons$); } } if($icons) { ... # do something with these lines } }

$icons may not be declared inside the loop, or it'll be undef next time you go through the loop.