my ($points, $quota) = @_; my %compare = ( 18000 => 24, 16000 => 23, 14000 => 22, ... ); for my $key (sort {$b <=> $a} keys %compare) { if ($points > $key and $quota < $compare{$key}) { return $compare{key}; } } return 15;