line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::PT::Nums2Ords; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
141132
|
use 5.006; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
295
|
|
4
|
3
|
|
|
3
|
|
20
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
151
|
|
5
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
161
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
4451
|
use Lingua::PT::Nums2Words qw/num2word/; |
|
3
|
|
|
|
|
7967
|
|
|
3
|
|
|
|
|
3635
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
14
|
|
|
|
|
|
|
num2ord |
15
|
|
|
|
|
|
|
) ] ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT = qw( |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Lingua::PT::Nums2Ords - Converts numbers to Portuguese ordinals |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Lingua::PT::Nums2Ords qw/num2ord/; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$ord = num2ord(20) # "vigesimo" |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
@ord = num2ord(1,2,3) # qw(primeiro segundo terceiro) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Converts numbers to Portuguese ordinals. Works up to 999.999.999.999 |
39
|
|
|
|
|
|
|
('novecentos e noventa e nove bilionesimos novecentos e noventa e |
40
|
|
|
|
|
|
|
nove milionesimos novecentos e noventa e nove milesimos nongentesimo |
41
|
|
|
|
|
|
|
nonagesimo nono'). |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 num2ord |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This is the only function in the module. It turns a number into an |
46
|
|
|
|
|
|
|
ordinal. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$ord = num2ord(2) |
49
|
|
|
|
|
|
|
# $ord now holds "segundo" |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub num2ord { |
54
|
51
|
100
|
|
51
|
1
|
194
|
@_ || return (); |
55
|
50
|
100
|
|
|
|
175
|
my @numbers = wantarray ? @_ : shift; |
56
|
52
|
50
|
|
|
|
113
|
my @results = map { |
57
|
50
|
|
|
|
|
88
|
$_ < 0 && return $_; |
58
|
52
|
50
|
|
|
|
92
|
$_ > 999999999999 && return $_; |
59
|
|
|
|
|
|
|
|
60
|
52
|
|
|
|
|
233
|
s/(?
|
61
|
52
|
|
|
|
|
265
|
s/(\d{1,3})(?=\d{9})/num2word($1).' bilionésimos '/e; |
|
8
|
|
|
|
|
24
|
|
62
|
|
|
|
|
|
|
|
63
|
52
|
|
|
|
|
500
|
s/(?
|
64
|
|
|
|
|
|
|
|
65
|
52
|
|
|
|
|
91
|
s/(?
|
66
|
52
|
|
|
|
|
169
|
s/(\d{1,3})(?=\d{6})/num2word($1).' milionésimos '/e; |
|
8
|
|
|
|
|
21
|
|
67
|
|
|
|
|
|
|
|
68
|
52
|
|
|
|
|
517
|
s/(?
|
69
|
|
|
|
|
|
|
|
70
|
52
|
|
|
|
|
98
|
s/(?
|
71
|
52
|
|
|
|
|
316
|
s/(\d{1,3})(?=\d{3})/num2word($1).' milésimos '/e; |
|
14
|
|
|
|
|
39
|
|
72
|
|
|
|
|
|
|
|
73
|
52
|
|
|
|
|
867
|
s/(?
|
74
|
|
|
|
|
|
|
|
75
|
52
|
|
|
|
|
105
|
s/9(?=\d\d)/nongentésimo /; |
76
|
52
|
|
|
|
|
73
|
s/8(?=\d\d)/octigentésimo /; |
77
|
52
|
|
|
|
|
68
|
s/7(?=\d\d)/septigentésimo /; |
78
|
52
|
|
|
|
|
69
|
s/6(?=\d\d)/seiscentésimo /; |
79
|
52
|
|
|
|
|
71
|
s/5(?=\d\d)/quingentésimo /; |
80
|
52
|
|
|
|
|
333
|
s/4(?=\d\d)/quadrigentésimo /; |
81
|
52
|
|
|
|
|
73
|
s/3(?=\d\d)/tricentésimo /; |
82
|
52
|
|
|
|
|
63
|
s/2(?=\d\d)/ducentésimo /; |
83
|
52
|
|
|
|
|
74
|
s/1(?=\d\d)/centésimo /; |
84
|
|
|
|
|
|
|
|
85
|
52
|
|
|
|
|
95
|
s/(?
|
86
|
|
|
|
|
|
|
|
87
|
52
|
|
|
|
|
77
|
s/9(?=\d)/nonagésimo /; |
88
|
52
|
|
|
|
|
68
|
s/8(?=\d)/octogésimo /; |
89
|
52
|
|
|
|
|
64
|
s/7(?=\d)/septuagésimo /; |
90
|
52
|
|
|
|
|
71
|
s/6(?=\d)/sexagésimo /; |
91
|
52
|
|
|
|
|
112
|
s/5(?=\d)/quinquagésimo /; |
92
|
52
|
|
|
|
|
67
|
s/4(?=\d)/quadragésimo /; |
93
|
52
|
|
|
|
|
67
|
s/3(?=\d)/trigésimo /; |
94
|
52
|
|
|
|
|
67
|
s/2(?=\d)/vigésimo /; |
95
|
52
|
|
|
|
|
80
|
s/1(?=\d)/décimo /; |
96
|
|
|
|
|
|
|
|
97
|
52
|
|
|
|
|
95
|
s/(?
|
98
|
|
|
|
|
|
|
|
99
|
52
|
|
|
|
|
78
|
s/9/nono/; |
100
|
52
|
|
|
|
|
73
|
s/8/oitavo/; |
101
|
52
|
|
|
|
|
63
|
s/7/sétimo/; |
102
|
52
|
|
|
|
|
95
|
s/6/sexto/; |
103
|
52
|
|
|
|
|
69
|
s/5/quinto/; |
104
|
52
|
|
|
|
|
70
|
s/4/quarto/; |
105
|
52
|
|
|
|
|
279
|
s/3/terceiro/; |
106
|
52
|
|
|
|
|
67
|
s/2/segundo/; |
107
|
52
|
|
|
|
|
81
|
s/1/primeiro/; |
108
|
|
|
|
|
|
|
|
109
|
52
|
|
|
|
|
153
|
s/ +$//; |
110
|
|
|
|
|
|
|
|
111
|
52
|
|
|
|
|
158
|
$_; |
112
|
|
|
|
|
|
|
} @numbers; |
113
|
|
|
|
|
|
|
|
114
|
50
|
100
|
|
|
|
936
|
return wantarray ? @numbers : $numbers[0]; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
__END__ |