in reply to Problems with XML::Dumper
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.... 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;
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: XML::Dumper
by theguvnor (Chaplain) on Jan 21, 2002 at 00:45 UTC | |
|
(jeffa) 2Re: XML::Dumper
by jeffa (Bishop) on Dec 09, 2002 at 16:04 UTC |