You are thinking about hashes of hashes in the incorrect way. Hash elements and array elements must be scalars, so when dealing with a complex structure you are really storing hash references (pointers to hashes) in the hash. So rather than the nested access approach you have, reading a deep entry should look like
$servers{$server}{$process}
which is short hand for
$servers{$server}->{$process}
This means, for iterating through a hash of hashes using keys, your code should look like:
foreach $server (keys %servers) #returns individual servers
{
print "$server\n";
foreach $process (keys %{$servers{$server}}) #returns individu
+al processes on a server
{
print "$process\n";
foreach $processPart (keys %{$servers{$server}{$proces
+s}}) # returns part of a process
{
print "$processPart\n";
}
}
}
For some more details on these types of structures, you should probably read perllol.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.