in reply to match and edit block of text

while (<>) { print '#' if $_ ne $/; print; }

You may have some other conditions to apply, but you didn't mention them.

After Compline,
Zaxo