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

Re: min and max in a hash of hash

by ikegami (Pope)
on Jul 12, 2010 at 06:12 UTC ( #848930=note: print w/ replies, xml ) Need Help??


in reply to min and max in a hash of hash

my ($max_y) = my ($min_y) = keys(%Year); my ($max_m) = my ($min_m) = keys(%{ $Year{$max_y} }); my $max = $Year{$max_y}{$max_m}; my $min = $Year{$min_y}{$min_m}; for my $y (keys(%Year)) { my $Month = $Year{$y}; for my $m (keys(%$Month)) { my $v = $Month->{$m}; if ($v < $min) { $min = $v; $min_y = $y; $min_m = $m; } elsif ($v > $max) { $max = $v; $max_y = $y; $max_m = $m; } } }

Update: I was initialising $max_y twice instead of initialising $min_m. Fixed.


Comment on Re: min and max in a hash of hash
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (20)
As of 2014-08-28 14:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (261 votes), past polls