With a bit of playing, XML::Twig has done the trick and given me what I want. Iget some weird behaviour after it though... The script keeps running and everything looks good, but then I get a segmentation fault as the script ends.
I know its as it end cos everything is fine, including the print "... fininshed!\n"; final line, before it segmentation faults. Weird. Still, I don't s'pose it matter at that point.