blib/lib/Lingua/POL/Numbers.pm

filter: Statementstmt 51.9% 105 / 202 Branchbran 31.2% 40 / 128 Conditioncond 21.6% 13 / 60 MC/DCmcdc 6.2% 2 / 32 Subroutinesub 82.6% 19 / 23 Podpod 100% 15 / 15 totaltotal 42.1% 194 / 460 CC 87 SCAR 45.5
CC
87
Cov
41%
SLOWNIE
160.9
Dziesiatki
151.5
KTys
90.0
CRAP 94.5
↑ Summary
1 # For Emacs: -*- mode:cperl; mode:folding; coding:utf-8 -*-
2  
3 package Lingua::POL::Numbers;
4 # ABSTRACT: Number 2 word conversion in POL.
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 vars qw($Idziesiatka);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use lib $ENV{PMLIB_INC};
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Export::Attrs;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # }}}
20 # {{{ var block
21 1 our $VERSION = '0.2603260';
22  
23 # }}}
24  
25 # {{{ new
26  
27 sub new {
28 1 ▶ my $class = shift;
Subroutine new: called CC=3 SCAR=11.4
Pod documented
29 1 ▶ my $number = shift || '';
Condition50%1/2
shift() || ''
l!l
01
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
30 1 $Idziesiatka=0;
31  
32 1 my $self = {};
33 1 bless $self, $class;
34  
35 1 ▶ if( $number =~ /\d+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($number =~ /\d+/u) 0 1 1
36 0 return( $self->parse($number) );
37 }
38  
39 1 return( $self );
40 }
41  
42 # }}}
43 # {{{ parse
44  
45 sub parse :Export {
46 3 ▶ my $self = shift;
Subroutine parse: called CC=1 SCAR=0.0
Pod documented
47 3 my $number = shift;
48  
49 3 return( SLOWNIE($number,0) );
50 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 # }}}
53 # {{{ currency
54  
55 sub currency {
56 0 ▶ my $self = shift;
Subroutine currency: not called CC=1 SCAR=6.9
Pod documented
57 0 my $number = shift;
58  
59 0 return( SLOWNIE($number,1) );
60 }
61  
62 # }}}
63 # {{{ SLOWNIE
64  
65 sub SLOWNIE {
66 3 ▶ my $Numer = shift // 0;
Subroutine SLOWNIE: called CC=31 SCAR=50.8
Pod documented
Condition100%2/2
shift() // 0
l!l
21
MC/DC100%1/1
shift() // 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
67 3 my $currency = shift;
68  
69 3 my ($temps, $tempd, $tempj, $zlote, $grosze, $Licznik, $grd, $grj, $MiejsceDz, $T_S, $SLOWNIE);
70  
71 3 ▶ if ($Numer == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Numer == 0) { } 1 2 3
72 1 ▶ if ($currency) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currency) { } 0 1 1
73 0 $SLOWNIE = "zero zl zero gr";
74 } else {
75 1 $SLOWNIE = "zero";
76 }
77 }
78 else {
79 2 ▶ if ($Numer > 9999999999999.99 || $Numer < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Numer > 9999999999999.99 or $Numer < 0) { } 1 1 2
Condition66%2/3
$Numer > "9999999999999.99" or $Numer < 0
l!l&&r!l&&!r
101
MC/DC50%1/2
$Numer > "9999999999999.99" or $Numer < 0
$Numer > "9999999999999.99" $Numer < 0
Truth table66%2/3
A or B
A= $Numer > "9999999999999.99"B= $Numer < 0
ABresult
1X1
011
000
80 #carp "out of range in $Numer";
81 1 $SLOWNIE = "out of range";
82 }
83 else {
84 1 $Numer = Trim($Numer);
85 1 $MiejsceDz = InStr($Numer);
86 1 ▶ if ($MiejsceDz > 0 && Right($Numer,2) ne "00") {
Branch: 2 branches
BranchTrueFalseTotal
if ($MiejsceDz > 0 and Right($Numer, 2) ne '00') { } 0 1 1
elsif ($currency) { } 0 1 1
Condition33%1/3
$MiejsceDz > 0 and Right($Numer, 2) ne "00"
!ll&&!rl&&r
100
MC/DC0%0/2
$MiejsceDz > 0 and Right($Numer, 2) ne "00"
$MiejsceDz > 0 Right($Numer, 2) ne "00"
Truth table33%1/3
A and B
A= $MiejsceDz > 0B= Right($Numer, 2) ne "00"
ABresult
0X0
100
111
87 0 ▶ if ($currency) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currency) { } 0 0 0
88 0 $grosze = Left(Mid($Numer, $MiejsceDz + 1)."00", 2);
89 0 $grd = Dziesiatki(Right($grosze, 2));
90 0 ▶ if ($Idziesiatka!=1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka != 1) 0 0 0
91 0 $grj = Jednostki(Right($grosze, 1));
92 }
93 0 $grosze = " ".$grd.$grj."gr";
94 0 $Numer = Trim(Left($Numer, $MiejsceDz - 1));
95 }
96 else {
97 0 carp "no decimals allowed in parse mode in $Numer";
98 0 $zlote = "no decimals allowed in parse mode in $Numer";
99 }
100 }
101 elsif ($currency) {
102 0 $grosze = " zero gr";
103 }
104 1 ▶ if ($Numer>0 && ($currency || !$MiejsceDz)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($Numer > 0 and $currency || !$MiejsceDz) { } 1 0 1
elsif ($currency or not $MiejsceDz) { } 0 0 0
Condition33%2/6
$Numer > 0 and $currency || !$MiejsceDz
!ll&&!rl&&r
001
$currency or not $MiejsceDz
l!l&&r!l&&!r
010
MC/DC0%0/3
$Numer > 0 and $currency || !$MiejsceDz
$Numer > 0 $currency not $MiejsceDz
Truth table25%1/4
A and B or not(C)
A= $Numer > 0B= $currencyC= not $MiejsceDz
ABCresult
0XX0
1000
11X1
1011
105 1 $Licznik = 1;
106 1 ▶ while ($Numer ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($Numer ne "") 1 1 2
107 1 $tempj = "";
108 1 ▶ $temps = Setki(Right("000".$Numer, 3)) // '';
Condition50%1/2
Setki(Right('000' . $Numer, 3)) // ""
l!l
10
MC/DC0%0/1
Setki(Right('000' . $Numer, 3)) // ""
Setki(Right('000' . $Numer, 3))
Truth table50%1/2
A
A= Setki(Right('000' . $Numer, 3))
Aresult
11
00
109 1 ▶ $tempd = Dziesiatki(Right("00".$Numer, 2)) // '';
Condition50%1/2
Dziesiatki(Right('00' . $Numer, 2)) // ""
l!l
10
MC/DC0%0/1
Dziesiatki(Right('00' . $Numer, 2)) // ""
Dziesiatki(Right('00' . $Numer, 2))
Truth table50%1/2
A
A= Dziesiatki(Right('00' . $Numer, 2))
Aresult
11
00
110 1 ▶ if ($Idziesiatka!=1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka != 1) 1 0 1
111 1 ▶ $tempj = Jednostki(Right($Numer, 1)) // '';
Condition50%1/2
Jednostki(Right($Numer, 1)) // ""
l!l
10
MC/DC0%0/1
Jednostki(Right($Numer, 1)) // ""
Jednostki(Right($Numer, 1))
Truth table50%1/2
A
A= Jednostki(Right($Numer, 1))
Aresult
11
00
112 }
113 1 ▶ if ($Licznik==1) {
Branch: 3 branches
BranchTrueFalseTotal
if ($Licznik == 1) { } 1 0 1
elsif ($Licznik == 2) { } 0 0 0
elsif ($Licznik == 3 or $Licznik == 4 or $Licznik == 5) { } 0 0 0
114 1 $T_S = $temps.$tempd.$tempj;
115 }
116 elsif ($Licznik==2) {
117 0 $T_S = $temps.$tempd.$tempj.KTys($Numer);
118 ▶ } elsif ($Licznik==3||$Licznik==4||$Licznik==5) {
Condition0%0/6
$Licznik == 3 or $Licznik == 4 or $Licznik == 5
l!l&&r!l&&!r
000
$Licznik == 3 or $Licznik == 4
l!l&&r!l&&!r
000
MC/DC0%0/3
$Licznik == 3 or $Licznik == 4 or $Licznik == 5
$Licznik == 3 $Licznik == 4 $Licznik == 5
Truth table0%0/4
A or B or C
A= $Licznik == 3B= $Licznik == 4C= $Licznik == 5
ABCresult
1XX1
01X1
0011
0000
119 0 $T_S = $temps.$tempd.$tempj.KMil($Numer, $Licznik);
120 }
121 1 ▶ $zlote = $T_S.($zlote // '');
Condition50%1/2
$zlote // ""
l!l
01
MC/DC0%0/1
$zlote // ""
$zlote
Truth table50%1/2
A
A= $zlote
Aresult
11
00
122  
123 1 ▶ if (length($Numer) > 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $Numer > 3) { } 0 1 1
124 0 $Numer = Left($Numer, length($Numer) - 3);
125 0 $Licznik++;
126 }
127 else {
128 1 $Numer = "";
129 }
130 }
131 ▶ } elsif ($currency || !$MiejsceDz) {
Condition0%0/3
$currency or not $MiejsceDz
l!l&&r!l&&!r
000
MC/DC0%0/2
$currency or not $MiejsceDz
$currency not $MiejsceDz
Truth table0%0/3
A or not(B)
A= $currencyB= not $MiejsceDz
ABresult
1X1
011
000
132 0 $zlote = "zero "
133 }
134 1 ▶ if ($Numer !~ /^\d+$/ or $Numer > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $Numer =~ /^\d+$/u or $Numer > -1) 1 0 1
Condition33%1/3
not $Numer =~ /^\d+$/u or $Numer > -1
l!l&&r!l&&!r
100
MC/DC0%0/2
not $Numer =~ /^\d+$/u or $Numer > -1
not $Numer =~ /^\d+$/u $Numer > -1
Truth table33%1/3
not(A) or B
A= not $Numer =~ /^\d+$/uB= $Numer > -1
ABresult
1X1
011
000
135 1 ▶ if ($currency) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currency) { } 0 1 1
136 0 $SLOWNIE = $zlote."zl".$grosze;
137 } else {
138 1 $SLOWNIE = $zlote;
139 }
140 }
141 }
142 }
143  
144 3 return $SLOWNIE;
145 }
146  
147 # }}}
148 # {{{ KTys
149  
150 sub KTys {
151 0 ▶ my $Numer = shift;
Subroutine KTys: not called CC=9 SCAR=45.0
Pod documented
152 0 my $KTys;
153 0 my $tys=Val(Right("000".$Numer, 3));
154  
155 0 ▶ if ($tys == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tys == 0) { } 0 0 0
156 0 $KTys = "";
157 }
158 else {
159 0 $tys = Val(Right($Numer, 2));
160 0 ▶ if ($tys == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tys == 1) { } 0 0 0
161 0 $KTys = "ąc ";
162 }
163 else {
164 0 ▶ if ($tys == 12 || $tys == 13 || $tys == 14) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tys == 12 or $tys == 13 or $tys == 14) { } 0 0 0
Condition0%0/6
$tys == 12 or $tys == 13 or $tys == 14
l!l&&r!l&&!r
000
$tys == 12 or $tys == 13
l!l&&r!l&&!r
000
MC/DC0%0/3
$tys == 12 or $tys == 13 or $tys == 14
$tys == 12 $tys == 13 $tys == 14
Truth table0%0/4
A or B or C
A= $tys == 12B= $tys == 13C= $tys == 14
ABCresult
1XX1
01X1
0011
0000
165 0 $KTys = "ęcy ";
166 }
167 else {
168 0 $tys = Val(Right($Numer, 1));
169 }
170 0 ▶ if ( $tys == 2 || $tys == 3 || $tys == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tys == 2 or $tys == 3 or $tys == 4) { } 0 0 0
Condition0%0/6
$tys == 2 or $tys == 3 or $tys == 4
l!l&&r!l&&!r
000
$tys == 2 or $tys == 3
l!l&&r!l&&!r
000
MC/DC0%0/3
$tys == 2 or $tys == 3 or $tys == 4
$tys == 2 $tys == 3 $tys == 4
Truth table0%0/4
A or B or C
A= $tys == 2B= $tys == 3C= $tys == 4
ABCresult
1XX1
01X1
0011
0000
171 0 $KTys = "ące ";
172 }
173 else {
174 0 $KTys = "ęcy ";
175 }
176 }
177 0 $KTys = "tysi".$KTys;
178 }
179  
180 0 return $KTys;
181 }
182  
183 # }}}
184 # {{{ KMil
185  
186 sub KMil {
187 0 ▶ my ($Numer, $L)=@_;
Subroutine KMil: not called CC=9 SCAR=45.0
Pod documented
188 0 my ($KMil,$mil);
189 0 my @RzadW;
190 0 $RzadW[3] = "milion";
191 0 $RzadW[4] = "miliard";
192 0 $RzadW[5] = "bilion";
193 0 $mil = Val(Right("000".$Numer, 3));
194 0 ▶ if ($mil == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mil == 0) { } 0 0 0
195 0 $KMil = "";
196 }
197 else {
198 0 $mil = Val(Right($Numer, 2));
199 0 ▶ if ($mil == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mil == 1) { } 0 0 0
200 0 $KMil = " ";
201 }
202 else {
203 0 ▶ if ($mil == 12 || $mil == 13 || $mil == 14) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mil == 12 or $mil == 13 or $mil == 14) { } 0 0 0
Condition0%0/6
$mil == 12 or $mil == 13 or $mil == 14
l!l&&r!l&&!r
000
$mil == 12 or $mil == 13
l!l&&r!l&&!r
000
MC/DC0%0/3
$mil == 12 or $mil == 13 or $mil == 14
$mil == 12 $mil == 13 $mil == 14
Truth table0%0/4
A or B or C
A= $mil == 12B= $mil == 13C= $mil == 14
ABCresult
1XX1
01X1
0011
0000
204 0 $KMil = "ów ";
205 }
206 else {
207 0 $mil = Val(Right($Numer, 1));
208 0 ▶ if ($mil == 2 || $mil == 3 || $mil == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mil == 2 or $mil == 3 or $mil == 4) { } 0 0 0
Condition0%0/6
$mil == 2 or $mil == 3 or $mil == 4
l!l&&r!l&&!r
000
$mil == 2 or $mil == 3
l!l&&r!l&&!r
000
MC/DC0%0/3
$mil == 2 or $mil == 3 or $mil == 4
$mil == 2 $mil == 3 $mil == 4
Truth table0%0/4
A or B or C
A= $mil == 2B= $mil == 3C= $mil == 4
ABCresult
1XX1
01X1
0011
0000
209 0 $KMil = "y ";
210 } else {
211 0 $KMil = "ów ";
212 }
213 }
214 }
215 0 $KMil = $RzadW[$L].$KMil;
216 }
217  
218 0 return $KMil;
219 }
220  
221 # }}}
222 # {{{ Setki
223  
224 sub Setki {
225 1 ▶ my $Numer=shift;
Subroutine Setki: called CC=10 SCAR=34.7
Pod documented
226 1 my ($setka, $wynik);
227 1 $setka = Val(Left($Numer, 1));
228 1 ▶ if ($setka == 1) {
Branch: 9 branches
BranchTrueFalseTotal
if ($setka == 1) { } 0 1 1
elsif ($setka == 2) { } 0 1 1
elsif ($setka == 3) { } 0 1 1
elsif ($setka == 4) { } 0 1 1
elsif ($setka == 5) { } 0 1 1
elsif ($setka == 6) { } 0 1 1
elsif ($setka == 7) { } 1 0 1
elsif ($setka == 8) { } 0 0 0
elsif ($setka == 9) { } 0 0 0
229 0 $wynik= "sto ";
230 } elsif ($setka == 2) {
231 0 $wynik = 'dwieście ';
232 } elsif ($setka == 3) {
233 0 $wynik = 'trzysta ';
234 } elsif ($setka == 4) {
235 0 $wynik = 'czterysta ';
236 } elsif ($setka == 5) {
237 0 $wynik = 'pięćset ';
238 } elsif ($setka == 6) {
239 0 $wynik = 'sześćset ';
240 } elsif ($setka == 7) {
241 1 $wynik = 'siedemset ';
242 } elsif ($setka == 8) {
243 0 $wynik = 'osiemset ';
244 } elsif ($setka == 9) {
245 0 $wynik = 'dziewięćset ';
246 } else {
247 0 $wynik = '';
248 }
249  
250 1 return $wynik;
251 }
252  
253 # }}}
254 # {{{ Dziesiatki
255  
256 sub Dziesiatki {
257 1 ▶ my $Number = shift;
Subroutine Dziesiatki: called CC=20 SCAR=50.2
Pod documented
258 1 my $wynik = '';
259  
260 1 $Idziesiatka = Val(Left($Number, 1));
261 1 ▶ if ($Idziesiatka == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka == 1) { } 0 1 1
262 0 my $valnum = Val($Number);
263 0 ▶ if ($valnum == 10) { $wynik = 'dziesięć '; }
Branch: 10 branches
BranchTrueFalseTotal
if ($valnum == 10) { } 0 0 0
elsif ($valnum == 11) { } 0 0 0
elsif ($valnum == 12) { } 0 0 0
elsif ($valnum == 13) { } 0 0 0
elsif ($valnum == 14) { } 0 0 0
elsif ($valnum == 15) { } 0 0 0
elsif ($valnum == 16) { } 0 0 0
elsif ($valnum == 17) { } 0 0 0
elsif ($valnum == 18) { } 0 0 0
elsif ($valnum == 19) { } 0 0 0
264 0 elsif ($valnum == 11) { $wynik = 'jedenaście '; }
265 0 elsif ($valnum == 12) { $wynik = 'dwanaście '; }
266 0 elsif ($valnum == 13) { $wynik = 'trzynaście '; }
267 0 elsif ($valnum == 14) { $wynik = 'czternaście '; }
268 0 elsif ($valnum == 15) { $wynik = 'piętnaście '; }
269 0 elsif ($valnum == 16) { $wynik = 'szesnaście '; }
270 0 elsif ($valnum == 17) { $wynik = 'siedemnaście '; }
271 0 elsif ($valnum == 18) { $wynik = 'osiemnaście '; }
272 0 elsif ($valnum == 19) { $wynik = 'dziewiętnaście '; }
273 }
274 else {
275 1 ▶ if ($Idziesiatka == 2) { $wynik = 'dwadzieścia '; }
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka == 2) 0 1 1
276 1 ▶ if ($Idziesiatka == 3) { $wynik = 'trzydzieści '; }
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka == 3) 0 1 1
277 1 ▶ if ($Idziesiatka == 4) { $wynik = 'czterdzieści '; }
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka == 4) 0 1 1
278 1 ▶ if ($Idziesiatka == 5) { $wynik = 'pięćdziesiąt '; }
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka == 5) 0 1 1
279 1 ▶ if ($Idziesiatka == 6) { $wynik = 'sześćdziesiąt '; }
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka == 6) 0 1 1
280 1 ▶ if ($Idziesiatka == 7) { $wynik = 'siedemdziesiąt '; }
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka == 7) 0 1 1
281 1 ▶ if ($Idziesiatka == 8) { $wynik = 'osiemdziesiąt '; }
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka == 8) 0 1 1
282 1 ▶ if ($Idziesiatka == 9) { $wynik = 'dziewięćdziesiąt '; }
Branch: 1 branch
BranchTrueFalseTotal
if ($Lingua::POL::Numbers::Idziesiatka == 9) 0 1 1
283 }
284  
285 1 return $wynik;
286 }
287  
288 # }}}
289 # {{{ Jednostki
290  
291 sub Jednostki {
292 1 ▶ my $Numer=shift;
Subroutine Jednostki: called CC=10 SCAR=34.3
Pod documented
293 1 my ($jedst, $wynik);
294 1 $jedst = Val(Right($Numer, 1));
295 1 ▶ if ($jedst == 1) {
Branch: 9 branches
BranchTrueFalseTotal
if ($jedst == 1) { } 0 1 1
elsif ($jedst == 2) { } 0 1 1
elsif ($jedst == 3) { } 0 1 1
elsif ($jedst == 4) { } 0 1 1
elsif ($jedst == 5) { } 0 1 1
elsif ($jedst == 6) { } 0 1 1
elsif ($jedst == 7) { } 1 0 1
elsif ($jedst == 8) { } 0 0 0
elsif ($jedst == 9) { } 0 0 0
296 0 $wynik = "jeden ";
297 } elsif ($jedst == 2) {
298 0 $wynik = "dwa ";
299 } elsif ($jedst == 3) {
300 0 $wynik = "trzy ";
301 } elsif ($jedst == 4) {
302 0 $wynik = "cztery ";
303 } elsif ($jedst == 5) {
304 0 $wynik = "pięć ";
305 } elsif ($jedst == 6) {
306 0 $wynik = "sześć ";
307 } elsif ($jedst == 7) {
308 1 $wynik = "siedem ";
309 } elsif ($jedst == 8) {
310 0 $wynik = "osiem ";
311 } elsif ($jedst == 9) {
312 0 $wynik = "dziewięć ";
313 }
314 1 return $wynik;
315 }
316  
317 # }}}
318 # {{{ Left
319  
320 sub Left {
321 2 ▶ my ($Numer, $count) = @_;
Subroutine Left: called CC=1 SCAR=0.0
Pod documented
322 2 $Numer = substr($Numer,0,$count);
323  
324 2 return $Numer;
325 }
326  
327 # }}}
328 # {{{ Right
329  
330 sub Right {
331 4 ▶ my ($Numer, $count) = @_;
Subroutine Right: called CC=1 SCAR=0.0
Pod documented
332 4 $Numer = substr($Numer,-$count);
333  
334 4 return $Numer;
335 }
336  
337 # }}}
338 # {{{ Trim
339  
340 sub Trim {
341 1 ▶ my $Numer = shift;
Subroutine Trim: called CC=1 SCAR=0.0
Pod documented
342 1 $Numer=~s/^\s+//;
343 1 $Numer=~s/\s+$//;
344  
345 1 return $Numer;
346 }
347  
348 # }}}
349 # {{{ Val
350  
351 sub Val {
352 3 ▶ my $Numer = shift;
Subroutine Val: called CC=1 SCAR=0.0
Pod documented
353  
354 3 $Numer=~s/\D//g;
355  
356 3 return $Numer;
357 }
358  
359 # }}}
360 # {{{ Mid
361  
362 sub Mid {
363 0 ▶ my ($Numer, $count) = @_;
Subroutine Mid: not called CC=1 SCAR=6.9
Pod documented
364  
365 0 return ($Numer = substr($Numer,$count-1));
366 }
367  
368 # }}}
369 # {{{ InStr
370  
371 sub InStr {
372 1 ▶ my $Numer = shift;
Subroutine InStr: called CC=2 SCAR=7.4
Pod documented
373 1 my $ret=0;
374 1 ▶ if ($Numer=~/^(\d+)\./) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Numer =~ /^(\d+)\./u) 0 1 1
375 0 $ret=length($1)+1;
376 }
377  
378 1 return $ret;
379 }
380  
381 # }}}
382  
383 1 1;
384  
385 # {{{ POD
386  
387 =pod
388  
389 =encoding utf-8
390  
391 =head1 NAME
392  
393 Lingua::POL::Numbers - Perl module for converting numeric values into their Polish equivalents
394  
395 =head1 VERSION
396  
397 version 0.2603260
398  
399 =head1 DESCRIPTION
400  
401 Number 2 word conversion in POL.
402  
403 This is PetaMem release in iso-639-3 namespace.
404  
405 =head1 SYNOPSIS
406  
407 use Lingua::POL::Numbers;
408  
409 my $numbers = Lingua::POL::Numbers->new;
410  
411 my $text = $numbers->parse( 123 );
412  
413 # prints 'sto dwadzieścia trzy'
414 print $text;
415  
416 my $currency = $numbers->currency ( 123.45 );
417  
418 # prints 'sto dwadzieścia trzy zl czterdzieści pięć gr'
419 print $currency;
420  
421 =head1 FUNCTIONS
422  
423 =over
424  
425 =item new
426  
427 Constructor
428  
429 =item parse
430  
431 Converts number into Polish
432  
433 =item Dziesiatki
434  
435 private
436  
437 =item InStr
438  
439 private
440  
441 =item Jednostki
442  
443 private
444  
445 =item KMil
446  
447 private
448  
449 =item KTys
450  
451 private
452  
453 =item Left
454  
455 private
456  
457 =item Mid
458  
459 private
460  
461 =item Right
462  
463 private
464  
465 =item SLOWNIE
466  
467 private
468  
469 =item Setki
470  
471 private
472  
473 =item Trim
474  
475 private
476  
477 =item Val
478  
479 private
480  
481 =item currency
482  
483 private
484  
485 =back
486  
487 =head1 KNOWN BUGS
488  
489 None, but that does not mean there are not any.
490  
491 =head1 AUTHORS
492  
493 initial coding:
494 Henrik Steffen E<lt>cpan@topconcepts.deE<gt>
495 specification, maintenance:
496 Richard C. Jelinek E<lt>rj@petamem.comE<gt>
497 maintenance, coding (2025-present):
498 PetaMem AI Coding Agents
499  
500 =head1 LICENSE
501  
502 Original license is not known.
503 PetaMem added Perl 5 licesne as default.
504  
505 =cut
506  
507 # }}}
↑ Summary