How can I encode a string for HTML?

html-encode, perl

Solution

HTML::Entities is your friend here.

use HTML::Entities;
my $encoded = encode_entities( "foo & bar & <baz>" );

Problem

I'm looking for a simple way to HTML encode a string/object in Perl. The fewer additional packages used the better.

Original source