http://www.perlmonks.org?node_id=471159

guice has asked for the wisdom of the Perl Monks concerning the following question:

I'm wondering if anybody has any simple code to create an XML file from a perl hash?

I have a system in place that has hundereds of client machines that runs a single self contained perl script which outputs a single data file. I want to convert this datafile to XML, but cannot guarentee that XML::Simple (and all it's dependencies) are installed on the remote systems. To combat this, I need the ability to output an XML document using standard looping.

I'm sure I can figure out the code myself, after lots of debugging and testing, but I wanted to check here first to see if anybody has such code already created. A search on XML just brought up posts about XML::Simple and related modules.

Thanks
-- philip
We put the 'K' in kwality!

  • Comment on Creating an XML file w/out external Libraries

Replies are listed 'Best First'.
Re: Creating an XML file w/out external Libraries
by saintmike (Vicar) on Jun 29, 2005 at 20:14 UTC
    I'd recommend that you use PAR to package up your script so that you can install and run it anywhere with a basic perl installation.

    This way, your target machine won't need to have XML::Simple installed, because it comes with the PAR package.

    This article shows a couple of use cases.

      Oh, hadn't herd of this one before. JAR for Perl. Looks quite interesting. I'll have to check this one out. Wow, if it runs like a real JAR, this'll make things much simpler. Thanks!

      -- philip
      We put the 'K' in kwality!

Re: Creating an XML file w/out external Libraries
by davidrw (Prior) on Jun 29, 2005 at 20:16 UTC
    what about PAR or similar for making sure XML::Simple or any other dependencies are packaged with your script? XML::Dumper is another one.. You can always copy code (or the whole package) from one of those into your .pl file (obviously not the best way to go -- see PAR).