| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lingua::EN::Numbers::Years; |
|
2
|
|
|
|
|
|
|
$Lingua::EN::Numbers::Years::VERSION = '1.02'; |
|
3
|
1
|
|
|
1
|
|
11793
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
49
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Lingua::EN::Numbers 1.01 qw(num2en); |
|
|
1
|
|
|
|
|
17
|
|
|
|
1
|
|
|
|
|
205
|
|
|
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
|
|
1269
|
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
|
2196
|
my $y = $_[0]; |
|
42
|
126
|
100
|
100
|
|
|
682
|
return undef unless defined $y and length $y; |
|
43
|
124
|
|
|
|
|
249
|
$y =~ s/,//g; |
|
44
|
124
|
100
|
100
|
|
|
868
|
if( $y =~ m/\d/ and $y =~ m/^(-?)(\d{1,5})$/s ) { |
|
45
|
121
|
100
|
|
|
|
350
|
my $neg = $1 ? "negative " : ''; |
|
46
|
121
|
|
|
|
|
343
|
local $_ = $2; |
|
47
|
121
|
100
|
|
|
|
244
|
return $Zero if $_ eq '0'; |
|
48
|
120
|
100
|
|
|
|
464
|
return "$neg$DD{$_}" if $DD{$_}; |
|
49
|
|
|
|
|
|
|
|
|
50
|
99
|
100
|
|
|
|
8291
|
m/^(..)000$/ and return "$neg$DD{$1} $T"; |
|
51
|
|
|
|
|
|
|
|
|
52
|
97
|
100
|
|
|
|
215
|
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
|
|
|
|
46
|
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
|
|
|
|
56
|
m/^(.0)0(..)$/ and return "$neg$DD{$1} $T $DD{$2}"; |
|
60
|
8
|
100
|
|
|
|
43
|
m/^(.0)(.)00$/ and return "$neg$DD{$1} $T $D{$2} $H"; |
|
61
|
6
|
50
|
|
|
|
66
|
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
|
|
|
|
189
|
m/^(.)000$/ and return "$neg$DD{$1} $T"; |
|
66
|
80
|
100
|
|
|
|
170
|
m/^(..)00$/ and return "$neg$DD{$1} $H"; |
|
67
|
78
|
100
|
|
|
|
156
|
m/^(.)00$/ and return "$neg$DD{$1} $H"; |
|
68
|
|
|
|
|
|
|
|
|
69
|
75
|
100
|
|
|
|
136
|
m/^(..)00(.)$/ and return "$neg$DD{$1} $Oh $Oh $DD{$2}"; |
|
70
|
74
|
100
|
|
|
|
178
|
m/^(..)0(..)$/ and return "$neg$DD{$1} $Oh $DD{$2}"; |
|
71
|
|
|
|
|
|
|
|
|
72
|
68
|
100
|
|
|
|
156
|
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
|
|
|
|
317
|
m/^(..)(.)(..)$/ and return "$neg$OhDD{$1} $D{$2} $OhDD{$3}"; |
|
76
|
34
|
100
|
|
|
|
228
|
m/^(..)(..)$/ and return "$neg$OhDD{$1} $OhDD{$2}"; |
|
77
|
13
|
50
|
|
|
|
135
|
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
|
|
|
|
|
12
|
return num2en($y); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
#-------------------------------------------------------------------------- |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |