use strict; use warnings; my @data = get_data(); # or however you get them my %count; foreach my $datum (@data) { ++$count{$datum}; } my %percentile; my $total = 0; foreach my $datum (sort { $a <=> $b } keys %count) { $percentile{$datum} = $total / @data * 100; $total += $count{$datum}; }
In reply to Re^5: optimize percentile counting in hash
by ikegami
in thread optimize percentile counting in hash
by max210
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |