#!/usr/local/bin/perl
use strict;
use Data::Dump qw[ pp ];
my %pvalues = (
1=> 0.5453980,
2=> 0.4902384,
3=> 0.8167950,
4=> 0.2821822,
5=> 0.4693030,
6=> 0.6491767,
7=> 0.9802138,
8=> 0.1155778,
9=> 0.9585124,
10=> 0.4069490
);
my @orderedKeys = sort {
$pvalues{ $b } <=> $pvalues{ $a }
} keys %pvalues;
my $d = my $n = values %pvalues;
$pvalues{ $_ } *= $n / $d-- for @orderedKeys;
pp \%pvalues;
__END__
c:\test>junk68
{
1 => "0.908996666666667",
2 => "0.9804768",
3 => "1.02099375",
4 => "1.410911",
5 => "1.1732575",
6 => "0.927395285714286",
7 => "0.9802138",
8 => "1.155778",
9 => "1.06501377777778",
10 => "1.35649666666667",
}
Of course, hash keys aren't intrinsically ordered, so you'll have to order them as needed for output, but one of the structure dumpers will do that for you.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|