#!/usr/bin/perl; use HTML::Entities; $to_decode = "TEST&TEST;A&E&an HTML--- string - <© TVS>"; #$decoded = decode_entities($to_decode); $encoded = encode_entities($to_decode); print "To decode --> $to_decode\n"; print "Encoded data --> $encoded\n"; #### To decode --> TEST&TEST;A&E&an HTML--- string - <© TVS> Encoded data --> TEST&TEST;A&E&an&nbsp;HTML---&nbsp;string - &lt;&copy; TVS&gt;