See your problem is you're using XML::Simple, switch to XML::Rules and your problem will go away :)
#!/usr/bin/perl --
#~ xml-simple-to-xml-rules-1089765.pl
#~ 2014-06-12-23:31:16 by Anonymous Monk
#~
#~
#~ perltidy -csc -otr -opr -ce -nibc -i=4
#!/usr/bin/perl --
use strict; use warnings;
use XML::Rules;
use XML::Simple qw/ XMLin /;
use Data::Dump qw/ dd /;
my $shortxmlraw = q{<?xml version='1.0'?>
<employees>
<employee>
<name>John Doe</name>
<age>43</age>
<sex>M</sex>
<department>Operations</department>
</employee>
<employee>
<name>Jane Doe</name>
<age>31</age>
<sex>F</sex>
<department>Accounts</department>
</employee>
</employees>};
my $xmlin = XML::Rules->new(
qw/ stripspaces 8 /,
rules => ## the result of xml2XMLRules foo.xml foo2.xml ....
{
'age,department,name,sex' => 'content',
'employee' => 'as array no content',
'employees' => 'no content'
},
);
dd({ YES => $xmlin->parse( $shortxmlraw ) });
dd({ NO => XMLin( $shortxmlraw ) });
__END__
{
YES => {
employees => {
employee => [
{ age => 43, department => "Operations", name => "John
+Doe", sex => "M" },
{ age => 31, department => "Accounts", name => "Jane Do
+e", sex => "F" },
],
},
},
}
{
NO => {
employee => {
"Jane Doe" => { age => 31, department => "Accounts", sex =
+> "F" },
"John Doe" => { age => 43, department => "Operations", sex
+ => "M" },
},
},
}