in reply to match and edit block of text
while (<>) { print '#' if $_ ne $/; print; } [download]
You may have some other conditions to apply, but you didn't mention them.
After Compline,Zaxo