in reply to escaping <!-- and --> in substitution...or other help plz

I'm pretty sure I got this from one of merlyn's columns:
$foo =~ s/['<&>"]/"&#".ord($&).";"/ge;