I am starting to think that this is a bug in XML::Dumper. I followed the Perl debugger and found this oddity:
... main::(foo.pl:16): $config = $dumper->xml2pl($xml); DB<1> s XML::Dumper::xml2pl(.../XML/Dumper.pm:114): 114: my ($obj,$tree) = @_; DB<1> n XML::Dumper::xml2pl(.../XML/Dumper.pm:117): 117: my $TopItem = $tree->[1]; DB<1> n XML::Dumper::xml2pl(.../XML/Dumper.pm:118): 118: my $ref = &Undump($TopItem); DB<1> s XML::Dumper::Undump(.../XML/Dumper.pm:133): 133: my ($Tree) = shift; DB<1> n XML::Dumper::Undump(.../XML/Dumper.pm:134): 134: my $ref = undef; DB<1> n XML::Dumper::Undump(.../XML/Dumper.pm:135): 135: my $FoundScalar; DB<1> n XML::Dumper::Undump(.../XML/Dumper.pm:136): 136: my $i; DB<1> n XML::Dumper::Undump(.../XML/Dumper.pm:138): 138: for ($i = 1; $i < $#$Tree; $i+=2) { DB<1> n XML::Dumper::Undump(.../XML/Dumper.pm:178): 178: $ref = $FoundScalar unless defined($ref); DB<1> n XML::Dumper::Undump(/.../XML/Dumper.pm:180): 180: done: 181: return ($ref); DB<1> n XML::Dumper::xml2pl(/.../XML/Dumper.pm:120): 120: return($ref); DB<1> n main::(foo.pl:21): print Dumper $config;
The problems i see are on lines 117 and 138 of XML/Dumper.pm. The code expects the argument to xml2pl to be an array ref, when it is really a scalar. The result is the for loop not being entered, and eventually an undef is returned.

Additionally, the synopsis code is inconsistent (if not broken) and once i 'fixed' and ran it, it produced the same results as your script - undef for the return value of xml2pl.

Personally, i'd just use XML::Simple. There maybe more configuration options to worry about, but i also think that you should worry about those config options.

My apologies in advance to the author of XML::Dumper if i am wrong. If nobody tells me contrary within about 24 hours then i will notify the author.

Update - i received a /msg from blakem that stated the same conclusion.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: XML::Dumper by jeffa
in thread Problems with XML::Dumper by theguvnor

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.