| 1 | # For Emacs: -*- mode:cperl; eval: (folding-mode 1); coding:utf-8 -*- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Lingua::DAN::Num2Word; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Number to word conversion in Danish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use 5.16.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # {{{ use block | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Export::Attrs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # {{{ variable declarations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my Readonly::Scalar $COPY = 'Copyright (c) PetaMem, s.r.o. 2002-present'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | our $VERSION = '0.2603270'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # {{{ num2dan_cardinal convert number to text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | sub num2dan_cardinal :Export { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | my $positive = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
num2dan_cardinal: called CC=23 SCAR=58.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | croak 'You should specify a number from interval [0, 999_999_999]' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not defined $positive && $positive =~ /\A\d+\z/msux or $positive < 0 or $positive > 999999999
not defined $positive && $positive =~ /\A\d+\z/msux or $positive < 0
defined $positive && $positive =~ /\A\d+\z/msux
MC/DC0%0/4
not defined $positive && $positive =~ /\A\d+\z/msux or $positive < 0 or $positive > 999999999
defined $positive
$positive =~ /\A\d+\z/msux
$positive < 0
$positive > 999999999
Truth table20%1/5
not(A && B) or C or D
A= defined $positiveB= $positive =~ /\A\d+\z/msuxC= $positive < 0D= $positive > 999999999
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | if !defined $positive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | || $positive !~ m{\A\d+\z}xms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | || $positive < 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | || $positive > 999_999_999; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | my @tokens1 = qw(nul en to tre fire fem seks syv otte ni ti elleve tolv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | my @teens = qw(tretten fjorten femten seksten sytten atten nitten); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | my @tokens2 = qw(tyve tredive fyrre halvtreds tres halvfjerds firs halvfems); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | return $tokens1[$positive] if ($positive >= 0 && $positive < 13); # 0 .. 12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$positive >= 0 and $positive < 13
MC/DC0%0/2
$positive >= 0 and $positive < 13
$positive >= 0
$positive < 13
Truth table33%1/3
A and B
A= $positive >= 0B= $positive < 13
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | return $teens[$positive - 13] if ($positive > 12 && $positive < 20); # 13 .. 19 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$positive > 12 and $positive < 20
MC/DC0%0/2
$positive > 12 and $positive < 20
$positive > 12
$positive < 20
Truth table0%0/3
A and B
A= $positive > 12B= $positive < 20
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $out; # string for return value construction | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | my $one_idx; # index for tokens1 array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $remain; # remainder | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($positive > 19 && $positive < 100) { # 20 .. 99 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
$positive > 19 and $positive < 100
MC/DC0%0/2
$positive > 19 and $positive < 100
$positive > 19
$positive < 100
Truth table0%0/3
A and B
A= $positive > 19B= $positive < 100
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $one_idx = int ($positive / 10); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $remain = $positive % 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $out = "$tokens1[$remain]og" if ($remain); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $out .= $tokens2[$one_idx - 2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ▶ | elsif ($positive > 99 && $positive < 1000) { # 100 .. 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$positive > 99 and $positive < 1000
MC/DC0%0/2
$positive > 99 and $positive < 1000
$positive > 99
$positive < 1000
Truth table0%0/3
A and B
A= $positive > 99B= $positive < 1000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $one_idx = int ($positive / 100); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $remain = $positive % 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # Danish uses "et" (neuter) before hundrede, not "en" (common) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | my $prefix = $one_idx == 1 ? 'et' : $tokens1[$one_idx]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $out = "${prefix}hundrede"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $out .= $remain ? num2dan_cardinal($remain) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ▶ | elsif ($positive > 999 && $positive < 1_000_000) { # 1000 .. 999_999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$positive > 999 and $positive < 1000000
MC/DC0%0/2
$positive > 999 and $positive < 1000000
$positive > 999
$positive < 1000000
Truth table0%0/3
A and B
A= $positive > 999B= $positive < 1000000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $one_idx = int ($positive / 1000); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $remain = $positive % 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $out = num2dan_cardinal($one_idx).'tusind'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $out .= $remain ? num2dan_cardinal($remain) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ▶ | elsif ( $positive > 999_999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$positive > 999999 and $positive < 1000000000
MC/DC0%0/2
$positive > 999999 and $positive < 1000000000
$positive > 999999
$positive < 1000000000
Truth table0%0/3
A and B
A= $positive > 999999B= $positive < 1000000000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | && $positive < 1_000_000_000) { # 1_000_000 .. 999_999_999 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $one_idx = int ($positive / 1000000); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $remain = $positive % 1000000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $out = num2dan_cardinal($one_idx) . ' million'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $out .= 'er' if ($one_idx > 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $out .= $remain ? ' ' . num2dan_cardinal($remain) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # {{{ num2dan_ordinal convert number to ordinal text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | sub num2dan_ordinal :Export { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my $number = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
num2dan_ordinal: not called CC=22 SCAR=62.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | croak 'You should specify a number from interval [1, 999_999_999]' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not defined $number && $number =~ /\A\d+\z/msux or $number < 1 or $number > 999999999
not defined $number && $number =~ /\A\d+\z/msux or $number < 1
defined $number && $number =~ /\A\d+\z/msux
MC/DC0%0/4
not defined $number && $number =~ /\A\d+\z/msux or $number < 1 or $number > 999999999
defined $number
$number =~ /\A\d+\z/msux
$number < 1
$number > 999999999
Truth table0%0/5
not(A && B) or C or D
A= defined $numberB= $number =~ /\A\d+\z/msuxC= $number < 1D= $number > 999999999
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | if !defined $number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | || $number !~ m{\A\d+\z}xms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | || $number < 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | || $number > 999_999_999; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # Fully irregular 1-3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | return 'første' if $number == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | return 'anden' if $number == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | return 'tredje' if $number == 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # Irregular 4-12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my %irregular = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 4 => 'fjerde', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 => 'femte', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 6 => 'sjette', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 => 'syvende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 => 'ottende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 9 => 'niende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 => 'tiende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 11 => 'ellevte', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 12 => 'tolvte', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | return $irregular{$number} if exists $irregular{$number}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # 13-19: teens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my %teens = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 13 => 'trettende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 14 => 'fjortende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 15 => 'femtende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 16 => 'sekstende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 17 => 'syttende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 18 => 'attende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 19 => 'nittende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return $teens{$number} if exists $teens{$number}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # Tens ordinal forms (exact multiples) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my %tens_ord = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 20 => 'tyvende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 30 => 'tredivte', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 40 => 'fyrretyvende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 50 => 'halvtredsindstyvende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 60 => 'tresindstyvende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 70 => 'halvfjerdsindstyvende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 80 => 'firsindstyvende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 90 => 'halvfemsindstyvende', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # 20-99 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if ($number < 100) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $tens = int($number / 10) * 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $ones = $number % 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return $tens_ord{$tens} if $ones == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # Compound: cardinal ones + "og" + tens ordinal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my @tokens1 = qw(nul en to tre fire fem seks syv otte ni); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | return $tokens1[$ones] . 'og' . $tens_ord{$tens}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # 100-999 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ($number < 1000) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $hundreds = int($number / 100); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $remain = $number % 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ($remain == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | my $prefix = $hundreds == 1 ? 'et' : num2dan_cardinal($hundreds); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return "${prefix}hundrede"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $prefix = $hundreds == 1 ? 'et' : num2dan_cardinal($hundreds); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return "${prefix}hundrede" . num2dan_ordinal($remain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # 1000-999_999 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ($number < 1_000_000) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $remain = $number % 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ($remain == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | return num2dan_cardinal(int($number / 1000)) . 'tusinde'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return num2dan_cardinal(int($number / 1000)) . 'tusind' . num2dan_ordinal($remain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # 1_000_000 - 999_999_999 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ($number < 1_000_000_000) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $millions = int($number / 1_000_000); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $remain = $number % 1_000_000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if ($remain == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $base = num2dan_cardinal($millions); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my $suf = $millions > 1 ? 'er' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | return "$base million${suf}te"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $base = num2dan_cardinal($millions); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | my $suf = $millions > 1 ? 'er' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | return "$base million${suf} " . num2dan_ordinal($remain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # {{{ capabilities declare supported features | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | sub capabilities { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | cardinal => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
capabilities: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ordinal => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||