[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] Evolution or devolution?
Here's three code snippets in 3 different chunks of code that do the
same thing... Is this progress? :)
j
First example I found...
my ($common_rate,$cnt);
foreach my $rate (keys %common_rates) {
if ($common_rates{$rate} >= $cnt) {
next if ($rate < $common_rate);
$common_rate = $rate;
$cnt = $common_rates{$rate};
}
}
Second example I found...
my ($highest_frequency) = reverse sort values %ratecount;
@rates = grep { $ratecount{$_} == $highest_frequency } @rates;
my @common = reverse sort @rates;
return $common[0];
Code I just wrote:
print [ sort { $common_rates{$b} <=> $common_rates{$a} } keys
%common_rates ]->[0];
http://cancerweb.ncl.ac.uk/cgi-bin/omd?query=devolution&action=Search+OM
D