So maybe $node->replace_with( $some_other_node->detach )->delete;
In reply to Re: Replace html nodes (HTML::Element treebuilder xpath) by Anonymous Monk in thread Replace html nodes by gsiglet