shawshankred: From your example, you seem to want the keys printed in alpha order. As a convenience, this approach uses a temporary hash reference for the particular hash sub-element you wish to print; of course, it also would be possible (but, IMO, less readable/maintainable) to always access needed elements from the top of the hash down. (The structure of the example HoH I used is less complex than that in the OP, but you get the idea.)

>perl -wMstrict -le "my %VeCog = ( Operations => { A => { Value => '1', Desc => 'Minmess', }, B => { Value => '10', }, C => { Value => '100', }, D => { Value => '1000', }, }, ); my $tmp_hashref = $VeCog{Operations}; for my $key (sort keys %$tmp_hashref) { print qq{$key:$tmp_hashref->{$key}->{Value}}; } " A:1 B:10 C:100 D:1000

Update: Also, take a look at the HASHES OF HASHES section ( Access and Printing of a HASH OF HASHES subsection) of the Data Structures Cookbook, perldsc.


In reply to Re: How to access the HAsh Reference Elements and Value from XML::Simple out put by AnomalousMonk
in thread 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.