| 1 | package WebService::CIA::Parser; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | require 5.005_62; | |||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use WebService::CIA; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | our $VERSION = '1.4'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | my $proto = shift; | |||||||||||||||||||
| 13 | 1 | my $source = shift; | |||||||||||||||||||
| 14 | 1 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 15 | 1 | my $self = {}; | |||||||||||||||||||
| 16 | 1 | bless ($self, $class); | |||||||||||||||||||
| 17 | 1 | return $self; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 1 | ▶ | sub parse { | ||||||||||||||||||
|
Subroutine
parse: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 1 | my ($self, $cc, $html) = @_; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 1 | my $data = { | |||||||||||||||||||
| 27 | 'URL - Flag' => $WebService::CIA::base_url . 'flags/' . $cc . '-flag.gif', | ||||||||||||||||||||
| 28 | 'URL - Map' => $WebService::CIA::base_url . 'maps/' . $cc . '-map.gif', | ||||||||||||||||||||
| 29 | 'URL' => $WebService::CIA::base_url . 'geos/' . $cc . '.html', | ||||||||||||||||||||
| 30 | 'URL - Print' => $WebService::CIA::base_url . 'print/' . $cc . '.html' | ||||||||||||||||||||
| 31 | }; | ||||||||||||||||||||
| 32 | 1 | ▶ | while ($html =~ m# | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | <td[^>]+ class="FieldLabel">.*? | ||||||||||||||||||||
| 34 | <div.*?> | ||||||||||||||||||||
| 35 | (.+?): | ||||||||||||||||||||
| 36 | .*?</div>.*? | ||||||||||||||||||||
| 37 | </td>.*? | ||||||||||||||||||||
| 38 | <td[^>]+> | ||||||||||||||||||||
| 39 | (.*?) | ||||||||||||||||||||
| 40 | (</td>|</table>) | ||||||||||||||||||||
| 41 | #xsg) { | ||||||||||||||||||||
| 42 | 1 | my $field = $1; | |||||||||||||||||||
| 43 | 1 | my $value = $2; | |||||||||||||||||||
| 44 | 1 | $field =~ s/\s+/ /sg; | |||||||||||||||||||
| 45 | 1 | $field =~ s/^\s*(.*?)\s*$/$1/; | |||||||||||||||||||
| 46 | 1 | $value =~ s/\s+/ /sg; | |||||||||||||||||||
| 47 | 1 | $value =~ s/^\s*(.*?)\s*$/$1/; | |||||||||||||||||||
| 48 | 1 | $value =~ s/\s*<br>\s*/\n/g; | |||||||||||||||||||
| 49 | 1 | $value =~ s/<\/?[^>+]>//g; | |||||||||||||||||||
| 50 | 1 | $data->{$field} = $value; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 1 | return $data; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 2 | 1; | |||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||