{ # closure for qm # build lookup hash my $point_step = 2000; my $point_max = 18000; my $quota_offset = 15; my %quota; foreach my $p ( 1..$point_max/$point_step ) { $quota{$p} = $p + $quota_offset; } sub qm { my ($points, $quota) = @_; # $points-1 handles "less than but not equal" $points = int(($points-1)/$point_step); if ( exists( $quota{$points} ) and ( $quota < $quota{$points} ) ) { return $quota{$points}; } else { return 15; } } # sub qm } # closure qm