line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PESEL::Generator; |
2
|
|
|
|
|
|
|
$PESEL::Generator::VERSION = '1.41'; |
3
|
|
|
|
|
|
|
#----------------------------------------------------------------------- |
4
|
3
|
|
|
3
|
|
138606
|
use warnings; |
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
104
|
|
5
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
69
|
|
6
|
3
|
|
|
3
|
|
49
|
use base "Exporter::Tiny"; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1640
|
|
7
|
|
|
|
|
|
|
#======================================================================= |
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw( pesel ); |
9
|
|
|
|
|
|
|
#======================================================================= |
10
|
|
|
|
|
|
|
sub new { |
11
|
1
|
|
|
1
|
1
|
108
|
return bless { }, $_[ 0 ]; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
#======================================================================= |
14
|
|
|
|
|
|
|
sub pesel { |
15
|
2
|
|
|
2
|
1
|
96
|
while( 1 ){ |
16
|
3
|
100
|
|
|
|
99
|
my $psl = sprintf( '%02d', 1 + rand 99 ) . |
17
|
|
|
|
|
|
|
sprintf( '%02d', 1 + rand 12 ) . |
18
|
|
|
|
|
|
|
sprintf( '%02d', 1 + rand 27 ) . |
19
|
|
|
|
|
|
|
sprintf( '%03d', 1 + rand 999 ) . |
20
|
|
|
|
|
|
|
sprintf( '%d' , rand > 0.5 ? 1 : 0 ) ; |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
|
|
19
|
my @dig = split( //, $psl ); |
23
|
3
|
|
|
|
|
16
|
my $chk = $dig[ 0 ] * 1 + $dig[ 1 ] * 3 + $dig[ 2 ] * 7 + $dig[ 3 ] * 9 + $dig[ 4 ] * 1 + $dig[ 5 ] * 3 + $dig[ 6 ] * 7 + $dig[ 7 ] * 9 + $dig[ 8 ] * 1 + $dig[ 9 ] * 3; |
24
|
3
|
|
|
|
|
10
|
my $lst = substr( $chk, -1, 1 ); |
25
|
|
|
|
|
|
|
|
26
|
3
|
100
|
|
|
|
27
|
return $psl . ( 10 - $lst ) if $lst; |
27
|
|
|
|
|
|
|
#return $psl . ( ( 10 - $lst ) % 10 ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
#======================================================================= |
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |