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