line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::BR::CEP; |
2
|
2
|
|
|
2
|
|
77657
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
74
|
|
4
|
2
|
|
|
2
|
|
2103
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
732
|
|
|
2
|
|
|
|
|
90
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.01; |
7
|
|
|
|
|
|
|
our @EXPORT_OK = |
8
|
|
|
|
|
|
|
qw( test_cep testa_cep cep_type tipo_cep cep_region regiao_cep ); |
9
|
|
|
|
|
|
|
|
10
|
20
|
|
|
20
|
1
|
259
|
sub test_cep { return $_[0] =~ m/^\d{5}-\d{3}$/ } |
11
|
|
|
|
|
|
|
*testa_cep = \&test_cep; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub tipo_cep { |
14
|
16
|
50
|
|
16
|
1
|
43
|
return '' unless test_cep( $_[0] ); |
15
|
|
|
|
|
|
|
|
16
|
16
|
|
|
|
|
35
|
my $suffix = substr $_[0], 6, 3; |
17
|
16
|
100
|
|
|
|
52
|
return 'logradouro' if $suffix < 900; |
18
|
13
|
100
|
|
|
|
43
|
return 'especial' if $suffix < 960; |
19
|
10
|
100
|
|
|
|
27
|
return 'promocionais' if $suffix < 970; |
20
|
7
|
100
|
100
|
|
|
46
|
return 'correios' if $suffix < 990 || $suffix == 999; |
21
|
3
|
|
|
|
|
13
|
return 'caixapostal'; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
*cep_type = \&tipo_cep; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub regiao_cep { |
26
|
2
|
50
|
|
2
|
1
|
436
|
return () unless test_cep( $_[0] ); |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
33
|
my %regioes = ( |
29
|
|
|
|
|
|
|
0 => ['sp'], |
30
|
|
|
|
|
|
|
1 => ['sp'], |
31
|
|
|
|
|
|
|
2 => [qw( rj es)], |
32
|
|
|
|
|
|
|
3 => ['mg'], |
33
|
|
|
|
|
|
|
4 => [qw( ba se )], |
34
|
|
|
|
|
|
|
5 => [qw( pe al pb rn )], |
35
|
|
|
|
|
|
|
6 => [qw( ce pi ma pa am ac ap rr )], |
36
|
|
|
|
|
|
|
7 => [qw( df go to mt mg ro )], |
37
|
|
|
|
|
|
|
8 => [qw( pr sc )], |
38
|
|
|
|
|
|
|
9 => ['rs'], |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
5
|
return @{ $regioes{ substr( $_[0], 0, 1 ) } }; |
|
2
|
|
|
|
|
16
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
*cep_region = \®iao_cep; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
42; |
46
|
|
|
|
|
|
|
__END__ |