use HTML::Entities; encode_entities( $some_var ); # or decode_entities( $some_var );