line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::FR::SSN;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
56762
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
615
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.00';
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _check_ssn {
|
9
|
9
|
|
|
9
|
|
15
|
my ($class, $ssn) = @_;
|
10
|
|
|
|
|
|
|
|
11
|
9
|
|
|
|
|
16
|
$ssn =~ s#\s+##g;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# SSN are 15 \d
|
14
|
9
|
100
|
|
|
|
36
|
return '' if ($ssn !~ /^\d{15}$/);
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# SSN begins with 1 or 2
|
17
|
5
|
50
|
|
|
|
22
|
return '' if ($ssn !~ /^(1|2)/);
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# SSN contains birth month (1 > 12)
|
20
|
5
|
|
|
|
|
13
|
my $birth = substr($ssn, 3, 2);
|
21
|
5
|
100
|
66
|
|
|
30
|
return '' if (($birth > 12) or ($birth == 0));
|
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
|
|
10
|
return $ssn;
|
24
|
|
|
|
|
|
|
}
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new {
|
27
|
5
|
|
|
5
|
1
|
28
|
my ($class, $ssn) = @_;
|
28
|
|
|
|
|
|
|
|
29
|
5
|
|
|
|
|
18
|
my $self = bless \$ssn, $class;
|
30
|
|
|
|
|
|
|
|
31
|
5
|
|
100
|
|
|
19
|
$ssn ||= '';
|
32
|
5
|
|
|
|
|
14
|
$ssn = $self->_check_ssn($ssn);
|
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
|
|
28
|
$self;
|
35
|
|
|
|
|
|
|
}
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub is_valid {
|
38
|
4
|
|
|
4
|
1
|
8
|
my $self = shift;
|
39
|
4
|
|
|
|
|
7
|
my $ssn = shift;
|
40
|
|
|
|
|
|
|
|
41
|
4
|
100
|
|
|
|
15
|
$$self = $self->_check_ssn($ssn) if ($ssn);
|
42
|
|
|
|
|
|
|
|
43
|
4
|
100
|
|
|
|
31
|
(substr($$self, 13, 2) == (97 - (substr($$self, 0, 13) % 97))) ? return 1 : return 0;
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub ssn {
|
47
|
9
|
|
|
9
|
1
|
14
|
my $self = shift;
|
48
|
9
|
|
|
|
|
10
|
my $ssn = shift;
|
49
|
|
|
|
|
|
|
|
50
|
9
|
100
|
|
|
|
26
|
$$self = $self->_check_ssn($ssn) if ($ssn);
|
51
|
|
|
|
|
|
|
|
52
|
9
|
|
|
|
|
36
|
return $$self;
|
53
|
|
|
|
|
|
|
}
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_sex {
|
56
|
1
|
|
|
1
|
1
|
2
|
my $self = shift;
|
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
6
|
return substr($$self, 0, 1);
|
59
|
|
|
|
|
|
|
}
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub get_birth_year {
|
62
|
1
|
|
|
1
|
1
|
3
|
my $self = shift;
|
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
6
|
return substr($$self, 1, 2);
|
65
|
|
|
|
|
|
|
}
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get_birth_month {
|
68
|
1
|
|
|
1
|
1
|
3
|
my $self = shift;
|
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
7
|
return substr($$self, 3, 2);
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub get_birth_department {
|
74
|
1
|
|
|
1
|
1
|
4
|
my $self = shift;
|
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
7
|
return substr($$self, 5, 2);
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1;
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__
|