sub readthefile { my ($file)= (@_); print qq(File=$file\n); my $xhtml = HTML::TreeBuilder::XPath->new; $xhtml->implicit_tags(1); $xhtml->parse_file($file) or die("Could not parse '$file' : $!\n"); for my $list ($xhtml->findnodes('/html/body//div/ul/li')) { if($list->is_empty) { print qq(DELETE\n); $list->delete(); # this line does not do what I thought it would :( } } print $xhtml->as_XML_indented; $xhtml->delete; return (1); }