sub weight { my $age = shift; return $age / $FACTOR; } #### $score = $item->totalVotes() * weight($item->age()); #### $score = 0; foreach $vote ($item->votes()) { $score += $vote->value() * weight($item->age() - $vote->age()); }