|Problems? Is your data what you think it is?|
BEWARE: THIN ICE!
Let us pretend, for this discussion, that I regard the sample in the OP as something approximating "clean html" (ah shucks; just say it: IMO, YMMV, that IS NOT clean; that's flat out ugly!) OK, back to pretending.
Suppose you have a partially "clean html" file to deal with... say something that contains a line not too different from yours...
where the originator, for whatever reason, knew that one can force a browser to render multiple, consecutive spaces by inserting a charentity space, between each pair of 0x20>s.
Simply converting each ampersand to its charentity will not produce the outcome you want; rather, you'll get something like this:
<B>TEXT & MORE TEXT</B><BR>FOO &nbsp; BARwhich will render as:
TEXT & MORE TEXT
Or, suppose the incoming html is badly formed (mis-nested, for example): you're still going to have to rely on the Mark I eyeball or one of the packages discussed elsewhere in this thread to "clean" that, unless the definition of "clean html" is restricted to enforcing use of character entities.
And, finally (by way of illustrating why my opening jape is not mere ill-temper) while the following is open to numerous criticisms (failure to use the "strict" doctype; loading up the keywords meta; style definitions included in-page rather than linked, etc, etc, etc) IT IS valid -- ie, "clean" -- html per w3c's 4.01 standard.:
FWIW, and without deprecating the desire to do this with Perl, you might consider the standalone version of Tidy for html or a commercial validator.