in reply to transform XML to XML

XML::Twig is geared for converting XML to a different XML document, and there also is XML::Rules (which I haven't used).

You can use XSLT, but personally I found that XSLT becomes a giant hassle when the structures of two documents wildly differ and you need to "remember" information for later use, something which is trivial in Perl.