in reply to Sending output to an xml file

If you are using the XML::Twig module, you have to open the file to writing, and pass the filehandle as an argument to the flush or flush_up_to method of XML::Twig.