Home : General : Perl Programming :

General: Perl Programming: Re: [Bmxer] Percentage: Edit Log

Here is the list of edits for this post
Re: [Bmxer] Percentage
If you got everything into an array you could do:

Code:
my (@array) = qw( 3 4 7 1 4 1 2); #example
my ($high,$low);
my ($total) = scalar @array;

for (@array) {
if ($_ > 3) { $high++ } elsif ($_ < 4) { $low++ }
}

Then you can just do something like:

my $high_percent = sprintf("%.2f", (($high / $total) * 100));
my $low_percent = sprintf("%.2f", (($low / $total) * 100));

I _think_ that should work. You should end up with percentages for how many ratings are above/below 3.

There may be an easier way :)


Last edited by:

RedRum: Jan 6, 2002, 11:02 AM

Edit Log: