http://www.perlmonks.org?node_id=946585


in reply to Hierarchical tag closing

gugan:

First use a parser (e.g. HTML::TreeBuilder, XML::Twig) to create a data structure (I'd suggest a hash of hashes, aka HoH) to represent the data. Then write a function to traverse your HoH and create a new HoH structured the way you like it. Finally, traverse your new HoH and emit the text.

...roboticus

When your only tool is a hammer, all problems look like your thumb.