line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright (c) 2001, 2002 |
3
|
|
|
|
|
|
|
# Giulio Motta, Ivo Marino All rights reserved. |
4
|
|
|
|
|
|
|
# http://www-sms.sourceforge.net/ |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
7
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Telephone::Number; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
13
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
88
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION %DATA); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1796
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$VERSION = '0.09'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
%DATA = ( |
20
|
|
|
|
|
|
|
#Bulgaria |
21
|
|
|
|
|
|
|
359 => [88, 87], |
22
|
|
|
|
|
|
|
#Finland |
23
|
|
|
|
|
|
|
358 => [40, 50, 41], |
24
|
|
|
|
|
|
|
#France |
25
|
|
|
|
|
|
|
33 => [6], |
26
|
|
|
|
|
|
|
#Germany |
27
|
|
|
|
|
|
|
49 => [151, 160, 162, 152, 1520, 170..180, 163], |
28
|
|
|
|
|
|
|
#Italy |
29
|
|
|
|
|
|
|
39 => [330, 333..340, 360, 368, 340, 347..349, 328, 329, 380, 388, 389], |
30
|
|
|
|
|
|
|
#Russia |
31
|
|
|
|
|
|
|
7 => [901..903, 910], |
32
|
|
|
|
|
|
|
#Spain |
33
|
|
|
|
|
|
|
34 => [600, 605..610, 615..620, 626, 627, 629, 630, 636, 637, 639, |
34
|
|
|
|
|
|
|
646, 647, 649..662, 666, 667, 669, 670, 676..680, 686, 687, |
35
|
|
|
|
|
|
|
689, 690, 696, 697, 699], |
36
|
|
|
|
|
|
|
#United Kingdom |
37
|
|
|
|
|
|
|
44 => [qw/370 374 378 385 401 402 403 410 411 421 441 467 468 498 585 |
38
|
|
|
|
|
|
|
589 772 780 798 802 831 836 850 860 966 973 976 4481 4624 7000 |
39
|
|
|
|
|
|
|
7002 7074 7624 7730 7765 7771 7781 7787 7866 7939 7941 7956 7957 |
40
|
|
|
|
|
|
|
7958 7961 7967 7970 7977 7979 8700 9797/] |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
14
|
|
|
14
|
0
|
26
|
my $class = shift; |
45
|
14
|
50
|
|
|
|
23
|
croak "Wrong number of parameters" unless (grep {$_ == @_} (1, 3)); |
|
28
|
|
|
|
|
91
|
|
46
|
14
|
|
|
|
|
15
|
my $self; |
47
|
14
|
|
|
|
|
20
|
$_ = shift; |
48
|
14
|
50
|
|
|
|
40
|
s/^\+// unless (ref); |
49
|
14
|
50
|
|
|
|
34
|
($_, @_) = &parse_number($_) if (@_ == 0); |
50
|
14
|
|
|
|
|
60
|
$self = bless { |
51
|
|
|
|
|
|
|
intpref => $_, |
52
|
|
|
|
|
|
|
prefix => shift, |
53
|
|
|
|
|
|
|
telnum => shift, |
54
|
|
|
|
|
|
|
} , $class; |
55
|
14
|
|
|
|
|
53
|
$self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub fits { |
59
|
0
|
|
|
0
|
0
|
|
my ($tn, $setn) = @_; |
60
|
0
|
|
|
|
|
|
for (keys %{$tn}) { |
|
0
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
next unless (defined $setn->{$_}); |
62
|
0
|
|
|
|
|
|
return 0 unless ( |
63
|
|
|
|
|
|
|
is_in($tn->{$_}, ( |
64
|
|
|
|
|
|
|
ref $setn->{$_} |
65
|
0
|
0
|
|
|
|
|
? @{$setn->{$_}} |
|
|
0
|
|
|
|
|
|
66
|
|
|
|
|
|
|
: $setn->{$_} |
67
|
|
|
|
|
|
|
) |
68
|
|
|
|
|
|
|
) |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub whole_number { |
75
|
0
|
|
|
0
|
0
|
|
my $tn = shift; |
76
|
0
|
|
|
|
|
|
return $tn->{intpref} . $tn->{prefix} . $tn->{telnum}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub parse_number { |
80
|
0
|
|
|
0
|
0
|
|
my $tn = shift; |
81
|
0
|
|
|
|
|
|
my ($intpref, $prefix, $telnum); |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
for (sort {length($b) <=> length($a)} keys %DATA) { |
|
0
|
|
|
|
|
|
|
84
|
0
|
0
|
0
|
|
|
|
$intpref = $_ and last if $tn =~ /^$_/; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
unless ($intpref) { |
88
|
0
|
|
|
|
|
|
carp "No matching international prefix found"; |
89
|
0
|
|
|
|
|
|
return (undef, undef, $tn); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$tn = substr($tn, length $intpref); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
for (sort { length($b) <=> length($a) } @{ $DATA{$intpref} }) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
if ($tn =~ /^$_/) { |
96
|
0
|
|
|
|
|
|
$prefix = $_; |
97
|
0
|
|
|
|
|
|
$telnum = substr($tn, length); |
98
|
0
|
|
|
|
|
|
last; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
unless ($prefix) { |
103
|
0
|
|
|
|
|
|
carp "No matching mobile phone provider found"; |
104
|
0
|
|
|
|
|
|
$telnum = $tn; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
return ($intpref, $prefix, $telnum); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub is_in { |
111
|
0
|
|
|
0
|
0
|
|
$_ = shift; |
112
|
0
|
|
|
|
|
|
for my $regexp (@_) { |
113
|
0
|
0
|
|
|
|
|
return 1 if (/^$regexp$/); |
114
|
|
|
|
|
|
|
} |
115
|
0
|
|
|
|
|
|
return 0; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |