Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Optimizing Iterating over a giant hash

by ruzam (Curate)
on Dec 26, 2009 at 20:00 UTC ( #814443=note: print w/replies, xml ) Need Help??


in reply to Re: Optimizing Iterating over a giant hash
in thread Optimizing Iterating over a giant hash

Fully agree with eliminating the multiple call to keys.

I'm also a big believer in reducing nested hash references. For the small price of assigning another variable, you can eliminate the cost of several steps of hash key lookups, and improve readability as a bonus.

my $temp; while (($entry,$temp) = each %my_hash) { foreach $timeStamp ( sort keys %$temp) { my $hash_ref = $temp->{$timeStamp}; my @tskeys = sort keys %$hash_ref; print $Hentry "$entry\t$timeStamp\t", scalar @tskeys; print $Hentry "\t$_\t", $hash_ref->{$_} for @tskeys; print $Hentry "\n"; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://814443]
help
Chatterbox?
[stevieb]: I finally got all of my tests to run against my App::RPi::EnvUI!! I am so pleased :) Now to add more tests, update the documentation, some code cleanup, put in production in my largest operation, and do a non-beta release

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-12-16 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (446 votes). Check out past polls.

    Notices?