Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re (tilly) 1: Accessing deeply burried arrays of hashes

by tilly (Archbishop)
on Jan 25, 2001 at 04:12 UTC ( [id://54165]=note: print w/replies, xml ) Need Help??


in reply to Accessing deeply burried arrays of hashes

Suggestion. Dereference one at a time as you enter the loop. The logic will be simpler, the syntax saner, and by avoiding nested hash lookups your code will be faster as well:
foreach my $key (sort keys %tophash) { my $value1 = $tophash{$key}; foreach my $subkey (sort keys %$value1) { my $value2 = $value1->{$subkey}; foreach my $val (sort @$value2 ) { print "$val\n"; } } }
UPDATE
Oops, forgot to do the second hash lookup. Fixed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-18 07:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found