Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Iterating over second key in HoH defined by reference

by Laurent_R (Canon)
on Apr 04, 2014 at 18:03 UTC ( [id://1081177]=note: print w/replies, xml ) Need Help??


in reply to Iterating over second key in HoH defined by reference

I don't really understand your context, but if you want to iterate through nested hashes, it is usually easier to use the values function, rather than the keys function. Just a short example on how easy it is:
use strict; use warnings; my %hash = ( A => { F => 1, G => "3A", H => 5 }, B => { F => 1, G => "3B", H => 5 }, C => { F => 1, G => "3C", H => 5 }, D => { F => 1, G => "3D", H => 5 }, E => { F => 1, G => "3E", H => 5 }, ); print "$_->{G} " for (values %hash);
which prints:
3A 3D 3C 3E 3B
Or, if you want to go through the values of the inner hashes:
print join " ", map {values %{$_}, "-"} values %hash;
Output:
5 1 3A - 5 1 3D - 5 1 3C - 5 1 3E - 5 1 3B -

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1081177]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found