line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convert::Number::Digits; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1496
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN |
6
|
|
|
|
|
|
|
{ |
7
|
1
|
|
|
1
|
|
42
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
8
|
1
|
|
|
1
|
|
18
|
use vars qw( %Digits $VERSION ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
351
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
2
|
$VERSION = "0.03"; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
672
|
%Digits =( |
13
|
|
|
|
|
|
|
toWestern => "0-9", |
14
|
|
|
|
|
|
|
toArabic => "\x{0660}-\x{0669}", |
15
|
|
|
|
|
|
|
toArabicIndic => "\x{06F0}-\x{06F9}", |
16
|
|
|
|
|
|
|
toDevanagari => "\x{0966}-\x{096F}", |
17
|
|
|
|
|
|
|
toBengali => "\x{09E6}-\x{09EF}", |
18
|
|
|
|
|
|
|
toGurmukhi => "\x{0A66}-\x{0A6F}", |
19
|
|
|
|
|
|
|
toGujarati => "\x{0AE6}-\x{0AEF}", |
20
|
|
|
|
|
|
|
toOriya => "\x{0B66}-\x{0B6F}", |
21
|
|
|
|
|
|
|
toTamil => "0\x{0BE7}-\x{0BEF}", |
22
|
|
|
|
|
|
|
toTelugu => "\x{0C66}-\x{0C6F}", |
23
|
|
|
|
|
|
|
toKannada => "\x{0CE6}-\x{0CEF}", |
24
|
|
|
|
|
|
|
toMalayalam => "\x{0D66}-\x{0D6F}", |
25
|
|
|
|
|
|
|
toThai => "\x{0E50}-\x{0E59}", |
26
|
|
|
|
|
|
|
toLao => "\x{0ED0}-\x{0ED9}", |
27
|
|
|
|
|
|
|
toTibetan => "\x{0F20}-\x{0F29}", |
28
|
|
|
|
|
|
|
toMyanmar => "\x{1040}-\x{1049}", |
29
|
|
|
|
|
|
|
toEthiopic => "0\x{1369}-\x{1371}", |
30
|
|
|
|
|
|
|
toKhmer => "\x{17E0}-\x{17E9}", |
31
|
|
|
|
|
|
|
toMongolian => "\x{1810}-\x{1819}", |
32
|
|
|
|
|
|
|
toLimbu => "\x{1946}-\x{194F}", |
33
|
|
|
|
|
|
|
toRomanUpper => "0\x{2160}-\x{2168}", |
34
|
|
|
|
|
|
|
toRomanLower => "0\x{2170}-\x{2178}", |
35
|
|
|
|
|
|
|
toFullWidth => "\x{FF10}-\x{FF19}", |
36
|
|
|
|
|
|
|
toOsmanya => "\x{104A0}-\x{104A9}", |
37
|
|
|
|
|
|
|
toBold => "\x{1D7CE}-\x{1D7D7}", |
38
|
|
|
|
|
|
|
toDoubleStruck => "\x{1D7D8}-\x{1D7E1}", |
39
|
|
|
|
|
|
|
toSansSerif => "\x{1D7E2}-\x{1D7EB}", |
40
|
|
|
|
|
|
|
toSansSerifBold => "\x{1D7EC}-\x{1D7F5}", |
41
|
|
|
|
|
|
|
toMonoSpace => "\x{1D7F6}-\x{1D7FF}" |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _setArgs |
48
|
|
|
|
|
|
|
{ |
49
|
280
|
|
|
280
|
|
585
|
my ($self, $number) = @_; |
50
|
|
|
|
|
|
|
|
51
|
280
|
50
|
|
|
|
1022
|
if ( $#_ > 1 ) { |
52
|
0
|
|
|
|
|
0
|
warn ( "too many arguments." ); |
53
|
0
|
|
|
|
|
0
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
280
|
100
|
|
|
|
1770
|
unless ( $number =~ /^\d+$/ ) { |
56
|
27
|
|
|
|
|
815
|
warn ( "$number is not a number." ); |
57
|
27
|
|
|
|
|
148
|
return; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
253
|
|
|
|
|
581
|
$self->{number} = $number; |
61
|
|
|
|
|
|
|
|
62
|
253
|
|
|
|
|
1616
|
1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub new |
67
|
|
|
|
|
|
|
{ |
68
|
1
|
|
|
1
|
0
|
740
|
my $class = shift; |
69
|
1
|
|
|
|
|
3
|
my $self = {}; |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
5
|
my $blessing = bless ( $self, $class ); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
8
|
$self->{number} = undef; |
74
|
|
|
|
|
|
|
|
75
|
1
|
50
|
0
|
|
|
5
|
$self->_setArgs ( @_ ) || return if ( @_ ); |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
3
|
$blessing; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub number |
82
|
|
|
|
|
|
|
{ |
83
|
560
|
|
|
560
|
0
|
813
|
my $self = shift; |
84
|
|
|
|
|
|
|
|
85
|
560
|
100
|
100
|
|
|
1889
|
$self->_setArgs ( @_ ) || return |
86
|
|
|
|
|
|
|
if ( @_ ); |
87
|
|
|
|
|
|
|
|
88
|
533
|
|
|
|
|
1186
|
$self->{number}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub convert |
93
|
|
|
|
|
|
|
{ |
94
|
280
|
|
|
280
|
1
|
142127
|
my $self = shift; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
# reset string if we've been passed one: |
98
|
|
|
|
|
|
|
# |
99
|
280
|
50
|
|
|
|
1426
|
$self->number ( @_ ) if ( @_ ); |
100
|
|
|
|
|
|
|
|
101
|
280
|
|
|
|
|
602
|
my $number = $self->number; |
102
|
280
|
100
|
|
|
|
1109
|
return $number if ( $number =~ /^[0-9]+$/ ); |
103
|
|
|
|
|
|
|
|
104
|
276
|
|
|
|
|
394
|
my $method = "toWestern"; |
105
|
276
|
|
|
|
|
1743
|
foreach my $script (keys %Digits) { |
106
|
8004
|
100
|
|
|
|
20660
|
next if ( $script eq $method ); |
107
|
7728
|
|
|
|
|
228530
|
eval "\$number =~ tr/$Digits{$script}/$Digits{$method}/"; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
276
|
|
|
|
|
2036
|
$number; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub toMethods |
115
|
|
|
|
|
|
|
{ |
116
|
1
|
|
|
1
|
1
|
29
|
sort keys %Digits; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub AUTOLOAD |
121
|
|
|
|
|
|
|
{ |
122
|
280
|
|
|
280
|
|
149584
|
my ($self, $number) = @_; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
280
|
|
|
|
|
2202
|
my ($method) = ( $AUTOLOAD =~ /::([^:]+)$/ ); |
126
|
280
|
50
|
33
|
|
|
1890
|
return unless ( $method && ($method ne "DESTROY") ); |
127
|
|
|
|
|
|
|
|
128
|
280
|
50
|
|
|
|
2505
|
return unless ( $Digits{$method} ); |
129
|
|
|
|
|
|
|
|
130
|
280
|
50
|
|
|
|
1646
|
$number = $self->{number} unless ( defined($number) ); |
131
|
|
|
|
|
|
|
|
132
|
280
|
|
|
|
|
1913
|
foreach my $script (keys %Digits) { |
133
|
8120
|
100
|
|
|
|
19566
|
next if ( $script eq $method ); |
134
|
1
|
|
|
1
|
|
8
|
eval "\$number =~ tr/$Digits{$script}/$Digits{$method}/"; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
18
|
|
|
7840
|
|
|
|
|
259032
|
|
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
280
|
|
|
|
|
1942
|
$number; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
######################################################### |
142
|
|
|
|
|
|
|
# Do not change this, Do not put anything below this. |
143
|
|
|
|
|
|
|
# File must return "true" value at termination |
144
|
|
|
|
|
|
|
1; |
145
|
|
|
|
|
|
|
########################################################## |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
__END__ |