in reply to Re: calculating the mode
in thread calculating the mode
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.while (<>) { $freq{$_}++ for split; }
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*
|
|---|