http://www.perlmonks.org?node_id=375471


in reply to Re: Golf: Fix de facto HTML comments
in thread Golf: Fix de facto HTML comments

I was thinking along the same lines too, but I had a different approach to it, which saved me three characters.

46 (but changes too much)
if we lookahead and lookbehind, we can lose the last "<!--$x-->" bit, and if we use $_ we can save 1 character from =~ and lose "my"
s/(?<=<!--)(.+?)(?=-->)/($_=$1);s|-|¬|g;$_/seg

He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

Chady | http://chady.net/