in reply to Split tags and words nicely

Those regulars are particularly hard to do well. You need a special pattern matching gizmo (i.e., not a regexp/DFA) that counts depth — I forget the name, which you can fake using a (?{ $counter++ }) method to keep track of which tag is closing what.

Your best bet is to choose HTML::TreeBuilder — which I adore — or XML::XPath, which merlyn seems to really like. If you choose to go the treebuilder route, check out "HTML::Tree(Builder) in 6 minutes," which covers the use of the look_down() function. I had never heard of that until I read that post, since the function isn't documented well in my opinion.

-Paul