in reply to Safer (and cleaner) way to print user-supplied text.

This isn't terribly clear, but it has the advantage of easily being able to define new "trouble" characters:
#assuming input is in $string $string=join('',map( m![<>\\/]! ? "#".char($_).";" : $_, split(//, $st +ring))); # ^^^^^^^ These are trouble characters