line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::PL::NIP; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
531
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
823
|
use Exporter::Easy ( OK => [ qw(is_valid_nip) ] ); |
|
1
|
|
|
|
|
1854
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
126
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
69
|
|
8
|
1
|
|
|
1
|
|
5
|
use List::Util qw(sum); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
246
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my @weights = qw(6 5 7 2 3 4 5 6 7); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub is_valid_nip { |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
0
|
15
|
my $nip = shift; |
17
|
|
|
|
|
|
|
|
18
|
2
|
50
|
|
|
|
7
|
croak "No NIP number provided" unless $nip; |
19
|
2
|
|
|
|
|
5
|
$nip =~ s/^PL//; |
20
|
2
|
50
|
|
|
|
15
|
croak "NIP number invalid" unless $nip =~ /^[0-9]{10}$/; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
14
|
my @nip = split "", $nip; |
23
|
2
|
|
|
|
|
6
|
my $check_sum = pop @nip; |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
7
|
my $verify_check_sum += sum( map { $nip[$_] * $weights[$_] } 0..$#nip ); |
|
18
|
|
|
|
|
56
|
|
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
6
|
$verify_check_sum %= 11; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
21
|
return $verify_check_sum == $check_sum; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |