I'm using XML::Simple to parse an XML file which I then want to use to write an output file in a very specific format. Thus, the output order is important.
As I understand it, when the XML is converted to the perl hashref the order is lost (because perl hashes have no order). But what about when an array is used by XML::Simple.
For example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>10.0</price>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.99</price>
</cd>
<cd>
<title>Hello</title>
<artist>Say Hello</artist>
<price>0001</price>
</cd>
</catalog>
gives us a data structure resembling:
$VAR1 = {
'cd' => [
{
'artist' => 'Bonnie Tyler',
'price' => '10.0',
'title' => 'Hide your heart'
},
{
'artist' => 'Dolly Parton',
'price' => '9.99',
'title' => 'Greatest Hits'
},
{
'artist' => 'Say Hello',
'price' => '0001',
'title' => 'Hello'
}
]
};
The 3 'cd' structures get inserted into an array, so is their order always going to be the same as they were in the input file?