line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Number::Phone::RO; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24929
|
use 5.014000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
602
|
use parent qw/Number::Phone/; |
|
1
|
|
|
|
|
374
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
220182
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
20
|
use re '/s'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
759
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub AREA_NAMES (); ## no critic (ProhibitSubroutinePrototypes) |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %cache; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _normalized { |
17
|
6
|
|
|
6
|
|
7
|
my ($nr) = @_; |
18
|
6
|
|
|
|
|
14
|
$nr =~ y/0-9+//cd; |
19
|
6
|
|
|
|
|
11
|
$nr =~ s/^[+]40//; |
20
|
6
|
|
|
|
|
27
|
$nr =~ s/^0//; |
21
|
6
|
|
|
|
|
11
|
$nr |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _analyze_number { |
25
|
6
|
|
|
6
|
|
9
|
my ($nr) = @_; |
26
|
6
|
|
|
|
|
8
|
my %info; |
27
|
|
|
|
|
|
|
|
28
|
6
|
100
|
|
|
|
23
|
return { valid => 0 } unless length $nr == 9; |
29
|
5
|
|
|
|
|
12
|
$info{valid} = 1; |
30
|
|
|
|
|
|
|
|
31
|
5
|
100
|
|
|
|
18
|
$info{geographic} = $nr =~ /^[23][3-6]/ ? 1 : 0; |
32
|
5
|
100
|
|
|
|
15
|
@info{qw/fixed_line mobile/} = (1, 0) if $nr =~ /^[23]/; |
33
|
5
|
100
|
|
|
|
14
|
@info{qw/fixed_line mobile/} = (0, 1) if $nr =~ /^7/; |
34
|
5
|
100
|
|
|
|
15
|
$info{tollfree} = $nr =~ /^800/ ? 1 : 0; |
35
|
5
|
100
|
|
|
|
13
|
$info{specialrate} = $nr =~ /^90/ ? 1 : 0; |
36
|
5
|
100
|
|
|
|
11
|
$info{adult} = 1 if $nr =~ /^906/; |
37
|
|
|
|
|
|
|
|
38
|
5
|
100
|
|
|
|
12
|
my $arealen = $nr =~ /^[23]1/ ? 2 : 3; |
39
|
5
|
|
|
|
|
10
|
$info{areacode} = substr $nr, 0, $arealen; |
40
|
5
|
|
|
|
|
11
|
$info{subscriber} = substr $nr, $arealen; |
41
|
|
|
|
|
|
|
|
42
|
5
|
|
|
|
|
12
|
\%info |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
28
|
|
|
28
|
|
26
|
sub _info { $cache{${$_[0]}} } |
|
28
|
|
|
|
|
148
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub new { |
48
|
6
|
|
|
6
|
1
|
1219
|
my ($class, $nr) = @_; |
49
|
6
|
|
|
|
|
14
|
$nr = _normalized $nr; |
50
|
6
|
|
|
|
|
14
|
$cache{$nr} = _analyze_number $nr; |
51
|
6
|
|
|
|
|
17
|
my $self = bless \$nr, $class; |
52
|
6
|
100
|
|
|
|
17
|
$self->is_valid ? $self : undef |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
6
|
|
|
6
|
1
|
13
|
sub is_valid { shift->_info->{valid} } |
56
|
3
|
|
|
3
|
1
|
10
|
sub is_geographic { shift->_info->{geographic} } |
57
|
2
|
|
|
2
|
1
|
6
|
sub is_fixed_line { shift->_info->{fixed_line} } |
58
|
2
|
|
|
2
|
1
|
6
|
sub is_mobile { shift->_info->{mobile} } |
59
|
2
|
|
|
2
|
1
|
5
|
sub is_tollfree { shift->_info->{tollfree} } |
60
|
1
|
|
|
1
|
1
|
5
|
sub is_specialrate { shift->_info->{specialrate} } |
61
|
1
|
|
|
1
|
1
|
3
|
sub is_adult { shift->_info->{adult} } |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
1
|
6
|
sub country_code { 40 } |
64
|
1
|
|
|
1
|
1
|
9
|
sub regulator { 'ANCOM, http://ancom.org.ro'} |
65
|
|
|
|
|
|
|
|
66
|
5
|
|
|
5
|
1
|
12
|
sub areacode { shift->_info->{areacode} } |
67
|
2
|
100
|
|
2
|
1
|
8
|
sub areaname { $_[0]->is_geographic ? AREA_NAMES->{substr $_[0]->areacode, 1} : undef } |
68
|
6
|
|
|
6
|
1
|
12
|
sub subscriber { shift->_info->{subscriber} } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub format { ## no critic (ProhibitBuiltinHomonyms) |
71
|
2
|
|
|
2
|
1
|
6
|
my ($self) = @_; |
72
|
2
|
|
|
|
|
6
|
join ' ', |
73
|
|
|
|
|
|
|
'+40', |
74
|
|
|
|
|
|
|
$self->areacode, |
75
|
|
|
|
|
|
|
(substr $self->subscriber, 0, 3), |
76
|
|
|
|
|
|
|
(substr $self->subscriber, 3); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
1
|
1
|
2
|
sub intra_country_dial_to { "0${$_[0]}" } |
|
1
|
|
|
|
|
5
|
|
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
101
|
use constant AREA_NAMES => { |
82
|
|
|
|
|
|
|
1 => 'București', |
83
|
|
|
|
|
|
|
30 => 'Suceava', |
84
|
|
|
|
|
|
|
31 => 'Botoșani', |
85
|
|
|
|
|
|
|
32 => 'Iași', |
86
|
|
|
|
|
|
|
33 => 'Neamț', |
87
|
|
|
|
|
|
|
34 => 'Bacău', |
88
|
|
|
|
|
|
|
35 => 'Vaslui', |
89
|
|
|
|
|
|
|
36 => 'Galați', |
90
|
|
|
|
|
|
|
37 => 'Vrancea', |
91
|
|
|
|
|
|
|
38 => 'Buzău', |
92
|
|
|
|
|
|
|
39 => 'Brăila', |
93
|
|
|
|
|
|
|
40 => 'Tulcea', |
94
|
|
|
|
|
|
|
41 => 'Constanța', |
95
|
|
|
|
|
|
|
42 => 'Călărași', |
96
|
|
|
|
|
|
|
43 => 'Ialomița', |
97
|
|
|
|
|
|
|
44 => 'Prahova', |
98
|
|
|
|
|
|
|
45 => 'Dâmbovița', |
99
|
|
|
|
|
|
|
46 => 'Giurgiu', |
100
|
|
|
|
|
|
|
47 => 'Teleorman', |
101
|
|
|
|
|
|
|
48 => 'Argeș', |
102
|
|
|
|
|
|
|
49 => 'Olt', |
103
|
|
|
|
|
|
|
50 => 'Vâlcea', |
104
|
|
|
|
|
|
|
51 => 'Dolj', |
105
|
|
|
|
|
|
|
52 => 'Mehedinți', |
106
|
|
|
|
|
|
|
53 => 'Gorj', |
107
|
|
|
|
|
|
|
54 => 'Hunedoara', |
108
|
|
|
|
|
|
|
55 => 'Caraș-Severin', |
109
|
|
|
|
|
|
|
56 => 'Timiș', |
110
|
|
|
|
|
|
|
57 => 'Arad', |
111
|
|
|
|
|
|
|
58 => 'Alba', |
112
|
|
|
|
|
|
|
59 => 'Bihor', |
113
|
|
|
|
|
|
|
60 => 'Sălaj', |
114
|
|
|
|
|
|
|
61 => 'Satu Mare', |
115
|
|
|
|
|
|
|
62 => 'Maramureș', |
116
|
|
|
|
|
|
|
63 => 'Bistrița-Năsăud', |
117
|
|
|
|
|
|
|
64 => 'Cluj', |
118
|
|
|
|
|
|
|
65 => 'Mureș', |
119
|
|
|
|
|
|
|
66 => 'Harghita', |
120
|
|
|
|
|
|
|
67 => 'Covasna', |
121
|
|
|
|
|
|
|
68 => 'Brașov', |
122
|
|
|
|
|
|
|
69 => 'Sibiu', |
123
|
1
|
|
|
1
|
|
5
|
}; |
|
1
|
|
|
|
|
1
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
__END__ |