in reply to XML::Simple => XMLout()

The XML wasn't valid, so I made a change at the start. Change <opt> to <opt/>. <opt> results in a premature end of data. Next, you'll need to use:
my $config = XMLin($foo, KeyAttr => 1, ForceArray => 1);
ForceArray by itself isn't enough. Here's what I got:
#!/usr/bin/perl use strict; use warnings; use XML::Simple qw(:strict); my $foo = '/root/Desktop/log.xml'; my $config = XMLin($foo, KeyAttr => 1, ForceArray => 1); use Data::Dumper::Concise; print Dumper($config);

Replies are listed 'Best First'.
Re^2: XML::Simple => XMLout()
by Anonymous Monk on Sep 07, 2011 at 18:07 UTC

    The first line of the XML data was <opt> and the last line of the XML data was </opt>.

    That looks like a valid matching pair of opening and closing tags to me. Not sure I follow why you're suggesting that the OP to change <opt> to <opt/>, which in my opinion would leave an orphaned </opt> tag at the end.

    Am I missing something?

      You're not missing something. I have to agree with you. To get it to work with XMLin though, that's what I had to do. I originally put the xml under __DATA__: I had to use <opt/> for that; however, I just noticed that when I call the xml as a file, then <opt> works as it should. Sorry for the confusion.