Here is the XML Data dumped using the Data Dumper.
$VAR1 = { 'Dev' : { 'NM' : { 'nmsAc' : 'Unknown', 'nmsA' : '0.0.0.0:0' }, 'eve' : { 'alert' : '1', 'debug' : '1' }, 'Com' : { 'cost' : '1', 'stre' : 'nco', }, 'VeCog' : { 'Operations' : { 'A' : { 'Value' : '1', 'Desc' : 'Minmess' }, 'B' : { 'Value' : '10', 'Desc' : 'Minmess' }, 'C' : { 'Value' : '100', 'Desc' : 'Minmess' }, 'D' : { 'Value' : '1000', 'Desc' : 'Minmess' }, } 'disc' : { 'con' : '0.0.0.0:0', 'int' : 'None' } } } };
Here is my Perl Code
use XML::Simple; use Data::Dumper; $xml = new XML::Simple; $data = $xml->XMLin("/home/nager.xml"); print "$data->{Dev}->{VeCog}->{Operations}->{C}->{Value}\n";
I can print the value of element C with the print statement but I cant get the names of the elements A, B, C and D under the Element Operations. I want to be able to print the Key value pairs like
A:1 B:10 C:100 D:1000
How do I do that.

In reply to How to access the HAsh Reference Elements and Value from XML::Simple out put by shawshankred

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.