in reply to How to validate HTML?

Regexp::Common could help you. For XHTML files, see Validating XHTML Update: the other mentioned modules seem to be more appropriate.