line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::PT::Nums2Ords;
|
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
149320
|
use 5.006;
|
|
3
|
|
|
|
|
20
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
61
|
|
5
|
3
|
|
|
3
|
|
15
|
use warnings;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
132
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1522
|
use Lingua::PT::Nums2Words qw/num2word/;
|
|
3
|
|
|
|
|
4355
|
|
|
3
|
|
|
|
|
2210
|
|
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.08';
|
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
|
318
|
@_ || return ();
|
55
|
50
|
100
|
|
|
|
186
|
my @numbers = wantarray ? @_ : shift;
|
56
|
|
|
|
|
|
|
my @results = map {
|
57
|
50
|
50
|
|
|
|
104
|
$_ < 0 && return $_;
|
|
52
|
|
|
|
|
163
|
|
58
|
52
|
50
|
|
|
|
112
|
$_ > 999999999999 && return $_;
|
59
|
|
|
|
|
|
|
|
60
|
52
|
|
|
|
|
200
|
s/(?
|
61
|
52
|
|
|
|
|
247
|
s/(\d{1,3})(?=\d{9})/num2word($1).' bilionésimos '/e;
|
|
8
|
|
|
|
|
23
|
|
62
|
|
|
|
|
|
|
|
63
|
52
|
|
|
|
|
732
|
s/(?
|
64
|
|
|
|
|
|
|
|
65
|
52
|
|
|
|
|
100
|
s/(?
|
66
|
52
|
|
|
|
|
148
|
s/(\d{1,3})(?=\d{6})/num2word($1).' milionésimos '/e;
|
|
8
|
|
|
|
|
22
|
|
67
|
|
|
|
|
|
|
|
68
|
52
|
|
|
|
|
701
|
s/(?
|
69
|
|
|
|
|
|
|
|
70
|
52
|
|
|
|
|
103
|
s/(?
|
71
|
52
|
|
|
|
|
143
|
s/(\d{1,3})(?=\d{3})/num2word($1).' milésimos '/e;
|
|
14
|
|
|
|
|
40
|
|
72
|
|
|
|
|
|
|
|
73
|
52
|
|
|
|
|
1214
|
s/(?
|
74
|
|
|
|
|
|
|
|
75
|
52
|
|
|
|
|
110
|
s/9(?=\d\d)/nongentésimo /;
|
76
|
52
|
|
|
|
|
90
|
s/8(?=\d\d)/octigentésimo /;
|
77
|
52
|
|
|
|
|
105
|
s/7(?=\d\d)/septigentésimo /;
|
78
|
52
|
|
|
|
|
83
|
s/6(?=\d\d)/seiscentésimo /;
|
79
|
52
|
|
|
|
|
90
|
s/5(?=\d\d)/quingentésimo /;
|
80
|
52
|
|
|
|
|
82
|
s/4(?=\d\d)/quadrigentésimo /;
|
81
|
52
|
|
|
|
|
113
|
s/3(?=\d\d)/tricentésimo /;
|
82
|
52
|
|
|
|
|
86
|
s/2(?=\d\d)/ducentésimo /;
|
83
|
52
|
|
|
|
|
89
|
s/1(?=\d\d)/centésimo /;
|
84
|
|
|
|
|
|
|
|
85
|
52
|
|
|
|
|
104
|
s/(?
|
86
|
|
|
|
|
|
|
|
87
|
52
|
|
|
|
|
88
|
s/9(?=\d)/nonagésimo /;
|
88
|
52
|
|
|
|
|
86
|
s/8(?=\d)/octogésimo /;
|
89
|
52
|
|
|
|
|
95
|
s/7(?=\d)/septuagésimo /;
|
90
|
52
|
|
|
|
|
83
|
s/6(?=\d)/sexagésimo /;
|
91
|
52
|
|
|
|
|
80
|
s/5(?=\d)/quinquagésimo /;
|
92
|
52
|
|
|
|
|
85
|
s/4(?=\d)/quadragésimo /;
|
93
|
52
|
|
|
|
|
82
|
s/3(?=\d)/trigésimo /;
|
94
|
52
|
|
|
|
|
85
|
s/2(?=\d)/vigésimo /;
|
95
|
52
|
|
|
|
|
80
|
s/1(?=\d)/décimo /;
|
96
|
|
|
|
|
|
|
|
97
|
52
|
|
|
|
|
101
|
s/(?
|
98
|
|
|
|
|
|
|
|
99
|
52
|
|
|
|
|
77
|
s/9/nono/;
|
100
|
52
|
|
|
|
|
86
|
s/8/oitavo/;
|
101
|
52
|
|
|
|
|
82
|
s/7/sétimo/;
|
102
|
52
|
|
|
|
|
94
|
s/6/sexto/;
|
103
|
52
|
|
|
|
|
88
|
s/5/quinto/;
|
104
|
52
|
|
|
|
|
84
|
s/4/quarto/;
|
105
|
52
|
|
|
|
|
106
|
s/3/terceiro/;
|
106
|
52
|
|
|
|
|
83
|
s/2/segundo/;
|
107
|
52
|
|
|
|
|
91
|
s/1/primeiro/;
|
108
|
|
|
|
|
|
|
|
109
|
52
|
|
|
|
|
132
|
s/ +$//;
|
110
|
|
|
|
|
|
|
|
111
|
52
|
|
|
|
|
178
|
$_;
|
112
|
|
|
|
|
|
|
} @numbers;
|
113
|
|
|
|
|
|
|
|
114
|
50
|
100
|
|
|
|
270
|
return wantarray ? @numbers : $numbers[0];
|
115
|
|
|
|
|
|
|
}
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1;
|
118
|
|
|
|
|
|
|
__END__
|