It is seldom a good idea to parse a mark-up language with a regular expression. Find and use a module from CPAN. I cannot offer any practical advice, but a quick search of CPAN suggest that you look into XML::Parser or XML::Node. Good Luck, Bill