line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::EN::Numbers::Years; |
2
|
|
|
|
|
|
|
$Lingua::EN::Numbers::Years::VERSION = '1.05'; |
3
|
1
|
|
|
1
|
|
9174
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Lingua::EN::Numbers 1.01 qw(num2en); |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
141
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $T = 'thousand'; |
13
|
|
|
|
|
|
|
my $H = 'hundred'; |
14
|
|
|
|
|
|
|
my $Oh = 'oh'; |
15
|
|
|
|
|
|
|
my $Zero = 'zero'; |
16
|
|
|
|
|
|
|
my %DD; |
17
|
|
|
|
|
|
|
my %OhDD; |
18
|
|
|
|
|
|
|
my %D; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @EXPORT = qw(year2en); |
21
|
|
|
|
|
|
|
|
22
|
1
|
50
|
|
1
|
|
1070
|
BEGIN { *DEBUG = sub () {0} unless defined &DEBUG } # setup a DEBUG constant |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#-------------------------------------------------------------------------- |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
@DD{ '00' .. '09' } = @DD{ '0' .. '9' } = @D{ '0' .. '9' } |
27
|
|
|
|
|
|
|
= @OhDD{ '0' .. '9' } |
28
|
|
|
|
|
|
|
= qw(oh one two three four five six seven eight nine); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
@OhDD{ '00' .. '09' } = map "$Oh $_", @D{ '0' .. '9' }; |
31
|
|
|
|
|
|
|
# Altho "oh oh" presumably is never used |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
for my $num ('10' .. '99') { |
34
|
|
|
|
|
|
|
$OhDD{$num} = $DD{$num} = num2en($num); |
35
|
|
|
|
|
|
|
DEBUG > 1 and print "$num = $DD{$num}\n"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#-------------------------------------------------------------------------- |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub year2en ($) { |
41
|
126
|
|
|
126
|
0
|
715
|
my $y = $_[0]; |
42
|
126
|
100
|
100
|
|
|
604
|
return undef unless defined $y and length $y; |
43
|
124
|
|
|
|
|
197
|
$y =~ s/,//g; |
44
|
124
|
100
|
100
|
|
|
741
|
if( $y =~ m/\d/ and $y =~ m/^(-?)(\d{1,5})$/s ) { |
45
|
121
|
100
|
|
|
|
276
|
my $neg = $1 ? "negative " : ''; |
46
|
121
|
|
|
|
|
226
|
local $_ = $2; |
47
|
121
|
100
|
|
|
|
245
|
return $Zero if $_ eq '0'; |
48
|
120
|
100
|
|
|
|
384
|
return "$neg$DD{$_}" if $DD{$_}; |
49
|
|
|
|
|
|
|
|
50
|
99
|
100
|
|
|
|
237
|
m/^(..)000$/ and return "$neg$DD{$1} $T"; |
51
|
|
|
|
|
|
|
|
52
|
97
|
100
|
|
|
|
236
|
if( m/^.0...$/ ) { |
53
|
|
|
|
|
|
|
# A family of troublesome cases: things like "60123". |
54
|
|
|
|
|
|
|
# We can't say "sixty one twenty-three" because that sounds |
55
|
|
|
|
|
|
|
# just like sixty-one twenty-three. So we special-case this |
56
|
|
|
|
|
|
|
# whole group. |
57
|
15
|
50
|
|
|
|
50
|
m/^(.0)000$/ and return "$neg$DD{$1} $T"; |
58
|
15
|
100
|
|
|
|
51
|
m/^(.0)00(.)$/ and return "$neg$DD{$1} $T $D{$2}"; |
59
|
12
|
100
|
|
|
|
61
|
m/^(.0)0(..)$/ and return "$neg$DD{$1} $T $DD{$2}"; |
60
|
8
|
100
|
|
|
|
32
|
m/^(.0)(.)00$/ and return "$neg$DD{$1} $T $D{$2} $H"; |
61
|
6
|
50
|
|
|
|
56
|
m/^(.0)(.)(..)$/ and return "$neg$DD{$1} $T $D{$2} $OhDD{$3}"; |
62
|
0
|
|
|
|
|
0
|
DEBUG and print "Falling thru with x0,xxx number $_ !\n"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
82
|
100
|
|
|
|
177
|
m/^(.)000$/ and return "$neg$DD{$1} $T"; |
66
|
80
|
100
|
|
|
|
170
|
m/^(..)00$/ and return "$neg$DD{$1} $H"; |
67
|
78
|
100
|
|
|
|
171
|
m/^(.)00$/ and return "$neg$DD{$1} $H"; |
68
|
|
|
|
|
|
|
|
69
|
75
|
100
|
|
|
|
156
|
m/^(..)00(.)$/ and return "$neg$DD{$1} $Oh $Oh $DD{$2}"; |
70
|
74
|
100
|
|
|
|
173
|
m/^(..)0(..)$/ and return "$neg$DD{$1} $Oh $DD{$2}"; |
71
|
|
|
|
|
|
|
|
72
|
68
|
100
|
|
|
|
152
|
m/^(.)00(.)$/ and return "$neg$DD{$1} $T $DD{$2}"; |
73
|
|
|
|
|
|
|
#m/^(..)00(.)$/ and return "$neg$DD{$1} $T $DD{$2}"; |
74
|
|
|
|
|
|
|
|
75
|
65
|
100
|
|
|
|
337
|
m/^(..)(.)(..)$/ and return "$neg$OhDD{$1} $D{$2} $OhDD{$3}"; |
76
|
34
|
100
|
|
|
|
183
|
m/^(..)(..)$/ and return "$neg$OhDD{$1} $OhDD{$2}"; |
77
|
13
|
50
|
|
|
|
105
|
m/^(.)(..)$/ and return "$neg$OhDD{$1} $OhDD{$2}"; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Else fallthru: |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
3
|
|
|
|
|
5
|
if(DEBUG) { |
83
|
|
|
|
|
|
|
my $x = num2en($y); |
84
|
|
|
|
|
|
|
print "Using superclass to return numerification \"$x\".\n"; |
85
|
|
|
|
|
|
|
return $x; |
86
|
|
|
|
|
|
|
} else { |
87
|
3
|
|
|
|
|
11
|
return num2en($y); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
#-------------------------------------------------------------------------- |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |