|
|
[Perlfect-search] Search scores in percents
JARED RUSSELL WHITE jrwhite@unix.amherst.edu
Mon, 21 Aug 2000 16:44:53 -0400 (EDT)
Thanks, Daniel -
That certainly is the right way to do it. I'm not really thinking too
clearly today!
If anybody else is interested, here's the code to handle that:
my @sortedList = sort {$answer{$b} <=> $answer{$a}} keys %answer;
my $percentFactor;
if (@sortedList) {
$percentFactor = 99.99/$answer{$sortedList[0]};
}
foreach (@sortedList[$first..$last]) {
my $score = sprintf "%.2f%%", $answer{$_} * $percentFactor;
...
Thanks, again, Dan.
- Jared White
On Mon, 21 Aug 2000, Daniel Naber wrote:
> On Mon, 21 Aug 2000, you wrote:
>
> > my $score = sprintf "%.2f%%", $answer{$_};
>
> You can do this and check if the value is > 100, if it is: $score = 100;
> (not a clean solution).
>
> The right way would be to go throw all the values in %answer and find the
> biggest one. Then you can calculate a factor that's necessary to make the
> biggest one 100 and multiply every value with this factor.
>
> Regards
> Daniel
> _______________________________________________
> perlfect-search mailing list
> perlfect-search@perlfect.com
>
>
|
|