$fee = determine_maximum_fee();
sub determine_total_fee {
Refactoring error? Is it determine_
maximum_fee() or determine_
total_fee? And that name that is overly verbose.
$fee = ($tfee / 100 + $sfee/100 + 0.0000001) * 100
...what in the world is this doing? If I had to guess, I'd say it is a hack to misuse
floating point numbers, instead of using something like
Math::Currency, although I'd expect to see some calls to int(). And it diddles with global variable $foo.
$mfee = 200 if ($fee >= 100);
...refers to global variables $mfee and $fee. And $mfee is non-descript. And we should at least have a comment explaining the magic numbers 100 and 200.
$fee = $mfee if $mfee;
...this is seems like it is probably a horrible hack to avoid warnings about undef.
return $fee;
}
I'd probably
not refactor into a subroutine, instead using a proper data type and something like...
use constant BREAK_POINT => 100;
use constant BONUS_FEE => 200;
my $total_fee = $tfee+$rfee >= BREAK_POINT ? BONUS_FEE : $tfee+$rfee;