| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package String::Normal::Type::Zip; |
|
2
|
9
|
|
|
9
|
|
27
|
use strict; |
|
|
9
|
|
|
|
|
10
|
|
|
|
9
|
|
|
|
|
177
|
|
|
3
|
9
|
|
|
9
|
|
25
|
use warnings; |
|
|
9
|
|
|
|
|
30
|
|
|
|
9
|
|
|
|
|
1842
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub transform { |
|
7
|
3
|
|
|
3
|
1
|
6
|
my ($self,$value) = @_; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# US 5 or 9 digit zip codes |
|
10
|
3
|
100
|
|
|
|
21
|
if ( $value =~ /^(\d{5})(?:[\-|\||\.|_|\s]*\d{4})?$/ ) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# trim zip9 down to 5 for now |
|
12
|
|
|
|
|
|
|
# TODO: add separate field for zip9 ( see revision 94419 for original code) |
|
13
|
2
|
|
|
|
|
10
|
return $1; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
elsif ($value =~ /^(apo|fpo)[\-|\||\.|_|\s]*aa[\-|\||\.|_|\s]*(\d{5})$/) { |
|
16
|
0
|
|
|
|
|
0
|
return $2; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
# Canada |
|
19
|
|
|
|
|
|
|
elsif ( $value =~ /^([a-z]\d[a-z])(\s|-|\||\.|_)*(\d[a-z]\d)$/ ) { |
|
20
|
1
|
|
|
|
|
3
|
$value = join '',$1,$3; |
|
21
|
1
|
|
|
|
|
5
|
return $value; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
else { |
|
24
|
0
|
|
|
|
|
0
|
die "Invalid zip code"; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
|
29
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
30
|
1
|
|
|
|
|
3
|
return bless {@_}, $self; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |