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