In regards to parsing XML, I would recommend using one of the many XML modules available on
CPAN. There is no need to write your own XML parser when several have allready been written and tested.
That being said, I would recommend
XML::Simple for this task.