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,23 +26,26 @@ sub main {
}
sub convert_number_to_words($number) {
my $return = '';
{
if ($number < 1) {
$return .= 'zero';
last;
}
append_millions_to_return(\$number, \$return);
append_thousand_hundreds(\$number, \$return);
append_decene_thousands(\$number, \$return);
append_hundred(\$number, \$return);
append_decene(\$number, \$return);
}
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 = '';
if ($number < 1) {
$return .= 'zero';
return $return;
}
append_millions_to_return(\$number, \$return);
append_thousand_hundreds(\$number, \$return);
append_decene_thousands(\$number, \$return);
append_hundred(\$number, \$return);
append_decene(\$number, \$return);
return $return;
}
sub append_decene($number_ref, $return_ref) {
my $number = ${$number_ref};
my $decene = int ($number / 1);
@ -78,13 +81,13 @@ sub convert_two_chars_number_to_words($number) {
{
if ($number < 20) {
$return .= $numbers_one_to_nineteen[$number-1];
last;
return $return;
}
my $decene = int($number / 10);
$return .= $decenes[$decene-1];
my $unit = $number % 10;
if ($unit < 1) {
last;
return $return;
}
$return .= '-';
$return .= $numbers_one_to_nine[$unit-1];