in reply to Re: calculating the mode
in thread calculating the mode

good. you can shorten your while loop a bit, though...

while (<>) { $freq{$_}++ for split; }
your @array variable was merely a temp, used to glue two statements together. split defaults to a whitespace split on $_, which is what <> is filling. i've flipped around the for loop, as well.

also, i wouldn't be so destructive to the sorted array. instead of popping the value, how about selecting it, by

my $mode = $sorted_array[-1]; ## aren't negative indexes neat?

~Particle *accelerates*