In PHP it's as simple as htmlspecialchars, how to do it in Perl?
htmlspecialchars
Use the HTML::Entities module.
use HTML::Entities; my $input = "<em>TEST</em>"; print(encode_entities($input));