in reply to Processing tagged text

This sounds like the sort of task Parse::RecDescent was created for. (IMHO a regex-based approach is a recipe for pain...) Take a look at Some Parse::RecDescent Tutorials - examples abound in the links therein.

HTH,

planetscape