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