in reply to regex matching issue
Without knowing the whole file I would recommend changing (.*) to (.+?) meaning "match at least one character but non-greedy"!
In general you should consider using one of the XML-moduls on CPAN...
Cheers Rolf