Siblings, I've got a nasty feeling this is going to be one of those nodes that stands as a lasting monument to my inability to see what's in front of my nose. But. I've got a data structure that prints out like this from Data::Dumper (just to be sure it really is the structure I want):
$VAR1 = {
'1' => {
'1' => {
'EMail' => 'norbert@thnwb.com',
'Name' => 'Norbert Bodkin'
},
'5' => {
'EMail' => 'sue@thnwb.com',
'Name' => 'Sue Soup'
}
},
'2' => {
'3' => {
'EMail' => 'max@thnwb.com',
'Name' => 'Max Grappler'
}
}
};
Now, say I want to print out everyone's name, ordered first by the key of the "outer" hash and then by the next hash in (
i.e. in this case exactly the order you see them above) I tried to do:
106 my $status;
107 for $status (keys %Status) {
108 for (keys %{ $Status{$status} }) {
109 print $Status{$status}{$_}{'Name'}, br;
110 }
111 }
(line numbers added for clarity) BUT... I get
Can't use string ("1") as a HASH ref while "strict refs" in use at /home/htdocs/hosted/thinweb/lib/devbox.pm line 108.
I tried a few other lame ways to do it which I won't go into her, but when I RTFMed, I found that my first cut was pretty much the staff solution... as far as I could tell. I even got superstitious and tried
105 my $status;
106 my $id;
107 for $status (keys %Status) {
108 for $id (keys %{ $Status{$status} }) {
109 print $Status{$status}{$id}{'Name'}, br;
110 }
111 }
... nada.
I'm stumped... I crave enlightenment... no matter how humiliating.
§
George Sherston
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.