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

Turn messy HTML into standards-compliant HTML with all close tags properly noted. Takes STDIN, or a list of files, and result goes on STDOUT.
#!/usr/bin/perl use XML::LibXML; print XML::LibXML->new->parse_html_string(join "", <>)->toStringHTML;