in reply to A Perl/CGI alternative to PHP's htmlentities()?

Another possibility: HTML::FromText:

use strict; use warnings; use HTML::FromText; my $text = '< René & François >'; my $t2h = HTML::FromText->new( ); my $html = $t2h->parse( $text ); print $html;

Output

&lt; Ren&eacute; &amp; Fran&ccedil;ois &gt;