Anyone experienced any problems with the
XML::Dumper module? I have previously used
XML::Simple to persistently store data, but was hoping to use XML::Dumper as it looked to be even simpler (less configuration options).
But, while I could make the pl2xml method work fine, I am unable to get it to convert the XML output back into a perl structure.
Here's a simplification of the code I'm using:
use XML::Dumper;
my $xml;
my %config = ('a key'=>'a value',
'another key'=>'another value');
my $dumper = XML::Dumper->new();
$xml = $dumper->pl2xml(\%config);
print "xml output: ", $xml;
my $config = $dumper->xml2pl($xml);
die "Uh oh" unless defined $config;
exit;
The above code prints out a snippet of xml just fine, but dies because the return from the call to xml2pl is undefined. I was under the impression it would return a reference to a perl data structure. Why does this method not reverse the process - I'm not even getting any indication of why it's failing!
Any help appreciated.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.