in reply to
Using HTML::TreeBuilder to insert content into nested divs
If it does what you want, the only question remaining is whether your test input is representative of your actual input. I'm not sure how we can answer that.
Comment on
Re: Using HTML::TreeBuilder to insert content into nested divs
In Section
Seekers of Perl Wisdom