use HTML::Entities; my $encoded = encode_entities($html); my $html = decode_entities( $encoded );