line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package No::OrgNr; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
208923
|
use utf8; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
36
|
|
4
|
7
|
|
|
7
|
|
238
|
use 5.014; |
|
7
|
|
|
|
|
16
|
|
5
|
7
|
|
|
7
|
|
22
|
use warnings; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
195
|
|
6
|
7
|
|
|
7
|
|
20
|
use open qw/:encoding(UTF-8) :std/; |
|
7
|
|
|
|
|
6
|
|
|
7
|
|
|
|
|
37
|
|
7
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
4059
|
use Net::Whois::Norid; |
|
7
|
|
|
|
|
364149
|
|
|
7
|
|
|
|
|
269
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$Net::Whois::Raw::CHECK_FAIL = 1; |
11
|
|
|
|
|
|
|
$Net::Whois::Raw::OMIT_MSG = 1; |
12
|
|
|
|
|
|
|
|
13
|
7
|
|
|
7
|
|
2895
|
use version; our $VERSION = qv('0.9.2'); |
|
7
|
|
|
|
|
8976
|
|
|
7
|
|
|
|
|
34
|
|
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
7
|
|
2996
|
use parent qw/Exporter/; |
|
7
|
|
|
|
|
1383
|
|
|
7
|
|
|
|
|
29
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw/all domain2orgnr num_domains orgnr_ok orgnr2domains/; |
17
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [qw/domain2orgnr num_domains orgnr_ok orgnr2domains/] ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub domain2orgnr { |
20
|
9
|
100
|
|
9
|
1
|
1029622
|
my $domain = shift or return; |
21
|
|
|
|
|
|
|
|
22
|
7
|
100
|
|
|
|
41
|
if ( $domain !~ / [.] no \z /x ) { |
23
|
3
|
|
|
|
|
10
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
42
|
return Net::Whois::Norid->new($domain)->id_number; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub num_domains { |
30
|
7
|
|
|
7
|
1
|
15
|
my $orgnr = shift; |
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
|
|
18
|
my @domains = orgnr2domains($orgnr); |
33
|
|
|
|
|
|
|
|
34
|
7
|
|
|
|
|
61
|
return scalar @domains; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub orgnr2domains { |
38
|
14
|
|
|
14
|
1
|
1198
|
my $orgnr = shift; |
39
|
|
|
|
|
|
|
|
40
|
14
|
|
|
|
|
21
|
my @domains; |
41
|
|
|
|
|
|
|
|
42
|
14
|
100
|
|
|
|
35
|
if ( !orgnr_ok($orgnr) ) { |
43
|
8
|
|
|
|
|
22
|
return @domains; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
6
|
|
|
|
|
13
|
$orgnr =~ s/ \s //gx; |
47
|
|
|
|
|
|
|
|
48
|
6
|
|
|
|
|
77
|
my $whois = Net::Whois::Norid->new($orgnr); |
49
|
6
|
|
|
|
|
558518
|
my $norid_handle = $whois->norid_handle; |
50
|
|
|
|
|
|
|
|
51
|
6
|
100
|
|
|
|
146
|
if ( !defined $norid_handle ) { |
52
|
2
|
|
|
|
|
22
|
return @domains; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
4
|
|
|
|
|
42
|
for my $nh ( split / \n /x, $norid_handle ) { |
56
|
18
|
|
|
|
|
176
|
my $nhobj = Net::Whois::Norid->new($nh); |
57
|
|
|
|
|
|
|
|
58
|
18
|
|
|
|
|
1893505
|
for my $domain ( split / /, $nhobj->domains ) { |
59
|
224
|
|
|
|
|
558
|
push @domains, $domain; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
4
|
|
|
|
|
149
|
return ( sort @domains ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub orgnr_ok { |
67
|
36
|
100
|
|
36
|
1
|
129
|
my $orgnr = shift or return 0; |
68
|
|
|
|
|
|
|
|
69
|
30
|
|
|
|
|
136
|
$orgnr =~ s/ \s //gx; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Valid numbers start on 8 or 9 |
72
|
30
|
100
|
|
|
|
118
|
if ( $orgnr !~ /\A [89] \d{8} \z/ax ) { |
73
|
16
|
|
|
|
|
66
|
return 0; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
14
|
|
|
|
|
115
|
my @d = split //, $orgnr; |
77
|
14
|
|
|
|
|
38
|
my $w = [ 3, 2, 7, 6, 5, 4, 3, 2 ]; |
78
|
14
|
|
|
|
|
27
|
my $sum = 0; |
79
|
14
|
|
|
|
|
48
|
for my $i ( 0 .. 7 ) { |
80
|
112
|
|
|
|
|
153
|
$sum += $d[$i] * $w->[$i]; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
14
|
|
|
|
|
28
|
my $rem = $sum % 11; |
84
|
14
|
100
|
|
|
|
43
|
my $control_digit = ( $rem == 0 ? 0 : 11 - $rem ); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Invalid number if control digit is 10 |
87
|
14
|
100
|
|
|
|
35
|
if ( $control_digit == 10 ) { |
88
|
1
|
|
|
|
|
8
|
return 0; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
13
|
100
|
|
|
|
36
|
if ( $control_digit != $d[8] ) { |
92
|
1
|
|
|
|
|
6
|
return 0; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
12
|
|
|
|
|
113
|
return $d[0] . $d[1] . $d[2] . ' ' . $d[3] . $d[4] . $d[5] . ' ' . $d[6] . $d[7] . $d[8]; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |