in reply to How to access the HAsh Reference Elements and Value from XML::Simple out put
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to access the HAsh Reference Elements and Value from XML::Simple out put
by shawshankred (Sexton) on Sep 17, 2010 at 13:53 UTC |