in reply to Deleting nodes with HTML::TreeBuilder::XPath

Changing if($list->is_empty) to if(!$list->is_empty) should do it.

Edit: Thanks to a tangent's answer I realised I misunderstood what you meant by "empty", as in "empty content", please ignore what I posted. Your script works for me, it deletes empty-content li items.