Removing last to have better practices.

This commit is contained in:
Sergiotarxz 2023-11-14 12:16:22 +01:00
parent d7a80c2c47
commit a9d0fe9017

View File

@ -26,20 +26,23 @@ sub main {
} }
sub convert_number_to_words($number) { sub convert_number_to_words($number) {
my $return = generate_number_without_uppercase_and_end_marks($number);
$return =~ s/(\w)/\U$1/;
$return .= '.';
return $return;
}
sub generate_number_without_uppercase_and_end_marks($number) {
my $return = ''; my $return = '';
{
if ($number < 1) { if ($number < 1) {
$return .= 'zero'; $return .= 'zero';
last; return $return;
} }
append_millions_to_return(\$number, \$return); append_millions_to_return(\$number, \$return);
append_thousand_hundreds(\$number, \$return); append_thousand_hundreds(\$number, \$return);
append_decene_thousands(\$number, \$return); append_decene_thousands(\$number, \$return);
append_hundred(\$number, \$return); append_hundred(\$number, \$return);
append_decene(\$number, \$return); append_decene(\$number, \$return);
}
$return =~ s/(\w)/\U$1/;
$return .= '.';
return $return; return $return;
} }
@ -78,13 +81,13 @@ sub convert_two_chars_number_to_words($number) {
{ {
if ($number < 20) { if ($number < 20) {
$return .= $numbers_one_to_nineteen[$number-1]; $return .= $numbers_one_to_nineteen[$number-1];
last; return $return;
} }
my $decene = int($number / 10); my $decene = int($number / 10);
$return .= $decenes[$decene-1]; $return .= $decenes[$decene-1];
my $unit = $number % 10; my $unit = $number % 10;
if ($unit < 1) { if ($unit < 1) {
last; return $return;
} }
$return .= '-'; $return .= '-';
$return .= $numbers_one_to_nine[$unit-1]; $return .= $numbers_one_to_nine[$unit-1];