http://www.perlmonks.org?node_id=1039101


in reply to Re^2: HTML::Entities encode_entities for perlmonks [ ]
in thread HTML::Entities encode_entities for perlmonks [ ]

Why not just encode the other characters manually?
use HTML::Entities ; my $string = '[< smarto >]'; my $unsafe_chars = '[]'; my $encoded = encode_entities($string) =~ s{([\Q$unsafe_chars\E])}{sprintf"&#%d;",ord$1}egr; print "$string\n$encoded\n";