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