Skip navigation.
Home
Your source for Perl tips, howto's, faq and tutorials
( categories: )

Some special symbols are frequently specified in HTML documents using HTML entities, this entities take the form &name;, like © for the copyright character.

In addition, any character can be specified in HTML in the form of numerical entities, that take the form &#number;, like © for the copyright character.

To convert this kind of HTML data to/from standard characters, you can use the functions 'decode_entities' and 'encode_entities' from HTML::Entities module.

Example:

#!/usr/bin/perl;
 
use HTML::Entities;
 
$to_decode = "an HTML string - <© TVS>";
$decoded = decode_entities($to_decode);
 
print "original data --> $to_decode\n";
print "decoded data --> $decoded\n";