I am trying to serialize the following data structure using XML :: Dumper
'options_settings' => { 'telnet.distinct.enable' => { 'text' => 'Option telnet.distinct.enable needs to be set to \'on\' as of workaround for Bug 476803', 'severity' => '7' } }, 'EOS_details' => { '338' => bless( { 'info' => '<a href="https://support.netapp.com/info/communications/ECMP1110462.html " target="_blank"> CPC-0705-02 </a>', 'count' => '48', 'ASUP_id' => 'AE20121117202086', 'part' => 'ESH2 - X5511A-RC, X5511-RC-C', 'category' => 'I/O Module', 'EOS_date' => '06/02/2013', 'severity' => '8' }, 'EOSObject' ),
The problem is that when I parse it into XML using XML: Dumper, it uses the same memory address for two separate hash links:
<item key="338"> <hashref blessed_package="EOSObject" memory_address="0x295b5758"> <item key="ASUP_id">AE20121117165273</item> <item key="EOS_date">06/02/2013</item> <item key="category">I/O Module</item> <item key="count">48</item> <item key="info"><a href="https://support.netapp.com/info/communications/ECMP1110462.html " target="_blank"> CPC-0705-02 </a></item> <item key="part">ESH2 - X5511A-RC, X5511-RC-C</item> <item key="severity">8</item> </hashref> </item> </hashref> <item key="options_settings"> <hashref memory_address="0x295b5320"> <item key="telnet.distinct.enable"> <hashref memory_address="0x295b5758"> </hashref> </item> </hashref> </item>
Pay attention to memory_address = "0x295b5758".
Therefore, when reading from a file, the option_settings hash link points to an EOS object: /
Is this a bug in XML :: Dumper or am I doing something wrong? Using the latest XML :: Dumper 0.81
PS I tried to play it outside the main script, and it works. However, I cannot understand why the data was broken in the main script. This is the code that uses XML :: Dumper:
DEBUG("Before serialization: " . Data::Dumper::Dumper($result)); my $dump = new XML::Dumper; my $dump_test = new XML::Dumper; my $test_xml = $dump_test->pl2xml ($result); DEBUG("After serialization in memory: " . Data::Dumper::Dumper($test_xml)); $dump->pl2xml( $result, $filename );
The result is printed correctly. "options_settings" are single entries. In $ test_xml it already mixes with EOS_details