line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Demo::Zipskinny; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20562
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
850
|
use LWP::Simple qw(); |
|
1
|
|
|
|
|
122741
|
|
|
1
|
|
|
|
|
2639
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.01; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
1
|
|
|
1
|
0
|
13
|
my ( $class, %arg ) = @_; |
10
|
1
|
|
|
|
|
8
|
return bless {}, $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub get { |
14
|
1
|
|
|
1
|
0
|
2
|
my ( $self, $zip ) = @_; |
15
|
1
|
50
|
|
|
|
5
|
return undef unless $zip =~ m/^\d{5}$/; |
16
|
1
|
|
|
|
|
8
|
my $content = LWP::Simple::get(qq(http://www.zipskinny.com/index.php?zip=$zip)); |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
720463
|
return $self->parse( $content ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub parse { |
22
|
2
|
|
|
2
|
0
|
5
|
my ( $self, $content ) = @_; |
23
|
2
|
|
|
|
|
5
|
my %res = (); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#yeah, it's crap, but it worked when i wrote it. stop complaining. |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
14
|
$content =~ m#"Demographic profile for ZIP Code \d{5} in (.+?), (\w{2})\."#; |
28
|
2
|
|
|
|
|
10
|
$res{'general'}{'city'} = $1; |
29
|
2
|
|
|
|
|
7
|
$res{'general'}{'state'} = $2; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
30
|
my ( $general ) = $content =~ m#General Information(.+?) |