You are actually right, although I don't really like how XML::Simple saves data structures.

Here is an example of what XML::Simple and XML::Dumper can do:

#!/bin/perl -w use strict; use XML::Simple; use XML::Dumper; my $struct= { toto => [1,2,3], tata => "duh", tutu => { tutu_toto => 1, tutu_tata => 2 }, }; my $out= XMLout( $struct); print "XML::Simple: $out\n"; my $dump = new XML::Dumper; print "XML::Dumper: ", $dump->pl2xml( $struct);

The result is:

XML::Simple: <opt tata="duh"> <tutu tutu_tata="2" tutu_toto="1" /> <toto>1</toto> <toto>2</toto> <toto>3</toto> </opt> XML::Dumper: <perldata> <hash> <item key="tata">duh</item> <item key="tutu"> <hash> <item key="tutu_tata">2</item> <item key="tutu_toto">1</item> </hash> </item> <item key="toto"> <array> <item key="0">1</item> <item key="1">2</item> <item key="2">3</item> </array> </item> </hash> </perldata>

I personnaly think the XML::Dumper way is cleaner but YMMV


In reply to Re: Re: Re: Re: Data::Dumper Efficiency Problem by mirod
in thread Data::Dumper Efficiency Problem by madhatter

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.