| 1 | package WWW::Search::AcronymFinder; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | our @ISA = qw(WWW::Search); | |||||||||||||||||||||||||||
| 10 | 1 | ▶ | use WWW::Search qw/generic_option/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | require WWW::SearchResult; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | my $MAINTAINER = 'xern <xern@cpan.org>'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub native_setup_search { | ||||||||||||||||||||||||||
|
Subroutine
native_setup_search: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 0 | my($self, $native_query, $native_options_ref) = @_; | |||||||||||||||||||||||||||
| 17 | 0 | $self->{_debug} = $native_options_ref->{'search_debug'}; | |||||||||||||||||||||||||||
| 18 | 0 | ▶ | $self->{_debug} = 0 if (!defined($self->{_debug})); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 0 | $self->{agent_e_mail} = 'xern@cpan.org'; | |||||||||||||||||||||||||||
| 20 | 0 | $self->user_agent('WWW::Search::AcronymFinder'); | |||||||||||||||||||||||||||
| 21 | 0 | $self->{_next_to_retrieve} = 1; | |||||||||||||||||||||||||||
| 22 | 0 | $self->{'_num_hits'} = 0; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if (!defined($self->{_options})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 0 | $self->{'search_base_url'} = 'http://www.acronymfinder.com/'; | |||||||||||||||||||||||||||
| 26 | $self->{_options} = { | ||||||||||||||||||||||||||||
| 27 | 0 | 'search_url' => 'http://www.acronymfinder.com/af-query.asp', | |||||||||||||||||||||||||||
| 28 | 'query' => $native_query, | ||||||||||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | my $function; | |||||||||||||||||||||||||||
| 33 | 0 | my %function = ( | |||||||||||||||||||||||||||
| 34 | 'reverse', 'on', | ||||||||||||||||||||||||||||
| 35 | 'wildcard', 'wildcard', | ||||||||||||||||||||||||||||
| 36 | 'prefix', 'off', | ||||||||||||||||||||||||||||
| 37 | 'exact' , 'exact' | ||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if (defined($native_options_ref)){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | foreach (keys %$native_options_ref) | |||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||
| 43 | $function= | ||||||||||||||||||||||||||||
| 44 | "String=".$function{$native_options_ref->{function}} | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if $function{$native_options_ref->{function}}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | my $options= | ||||||||||||||||||||||||||||
| 50 | 0 | join q/&/, grep{$_} "Acronym=".$self->{_options}->{query}, "Find=Find", $function; | |||||||||||||||||||||||||||
| 51 | 0 | $self->{_next_url} = $self->{_options}{'search_url'}.'?'.$options; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub native_retrieve_some { | ||||||||||||||||||||||||||
|
Subroutine
native_retrieve_some: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | return unless $self->{_next_url}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | my($response) = $self->http_request('GET', $self->{_next_url}); | |||||||||||||||||||||||||||
| 59 | 0 | $self->{response} = $response; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if($self->{_num_hits} && $response->{_content} =~ /returned (\d+) hits/so){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_num_hits"} and $response->{"_content"} =~ /returned (\d+) hits/so
MC/DC0%0/2
$self->{"_num_hits"} and $response->{"_content"} =~ /returned (\d+) hits/so
$self->{"_num_hits"}
$response->{"_content"} =~ /returned (\d+) hits/so
Truth table0%0/3
A and B
A= $self->{"_num_hits"}B= $response->{"_content"} =~ /returned (\d+) hits/so
| |||||||||||||||||||||||||||||
| 62 | 0 | $self->{_num_hits} = $1; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | while( $response->{_content} =~ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | m,<td valign="top" width="70%" bgcolor="#.+?">(?:<b>)?(.+?)(</b>)?\r\n</td>,mgo){ | ||||||||||||||||||||||||||||
| 67 | 0 | push @{$self->{cache}}, $1; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if( $response->{_content} =~ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | m,<a HREF="(af-query.asp\?acronym=.+?&String=.+?&page=\d+)"><font.+?><b>Next page,mo){ | ||||||||||||||||||||||||||||
| 72 | 0 | $self->{_next_url} = $self->absurl($self->{search_base_url}, $1)->as_string; | |||||||||||||||||||||||||||
| 73 | 0 | $self->{_next_url} =~ s/&/&/go; | |||||||||||||||||||||||||||
| 74 | 0 | return 1; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | return 0; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1 | 1; | |||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||