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 -
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.