Syntactic Confectionery Delight | |
PerlMonks |
Re: How to get the Max values' key!by Anno (Deacon) |
on Aug 13, 2007 at 10:29 UTC ( [id://632181]=note: print w/replies, xml ) | Need Help?? |
Finish it? You haven't offered any beginning to finish.
Here is one way: The code assumes that none of the second level hashes is empty, so the maximum always exists. If the maximum isn't unique (say if $r{123}{c} = 3 had also been given), a random key with the maximum value is selected. The solution is inefficient if the second level hashes are big because for each of them the full inverted hash is built just to pick out a single value. Anno
In Section
Seekers of Perl Wisdom
|
|