http://qs321.pair.com?node_id=790868


in reply to substitution on

If you want to replace < with &lt; where it is not part of an HTML tag, a simple solution would be using negative look ahead in your regex like this:
s/<(?![^<]*>)/&lt;/g;
A better solution would be using some HTML parsing module from CPAN.