#!perl -p0 s/<!-(-.*?-)->/ (my $x = $1) =~ tr,-,,s; $x = '--' if $x eq '-'; "<!-$ +x->" /gse;
UPDATE: Fixed so it no longer turns <!----> into <!--->. Thanks to extremely for pointing that out.
UPDATE: Caveat: don't use this code on files where Perl code may be embedded in an HTML comment, as in this HTML::Mason example: <!-- <% $x-- %> -->. Thanks to extremely for pointing this out too.
In reply to fix bad HTML comments by chipmunk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |