| 1 | package WWW::Mechanize; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | #ABSTRACT: Handy web browsing in a Perl object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 58 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 58 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 58 | our $VERSION = '2.21'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 58 | ▶ | use Tie::RefHash (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 58 | ▶ | use HTTP::Request 1.30 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 58 | ▶ | use HTML::Form 1.00 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 58 | ▶ | use HTML::TokeParser (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 58 | ▶ | use parent 'LWP::UserAgent'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 58 | our $HAS_ZLIB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 58 | ▶ | $HAS_ZLIB = eval { require Compress::Zlib; 1; }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 76 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 76 | my %parent_params = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | agent => "WWW-Mechanize/$VERSION", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | cookie_jar => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 76 | ▶ | my %mech_params = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | autocheck => ( $class eq 'WWW::Mechanize' ? 1 : 0 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | onwarn => \&WWW::Mechanize::_warn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | onerror => \&WWW::Mechanize::_die, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | quiet => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | stack_depth => 8675309, # Arbitrarily humongous stack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | headers => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | noproxy => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | strict_forms => 0, # pass-through to HTML::Form | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | verbose_forms => 0, # pass-through to HTML::Form | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | marked_sections => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 76 | my %passed_params = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # Keep the mech-specific params before creating the object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 76 | ▶ | while ( my ( $key, $value ) = each %passed_params ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 62 | ▶ | if ( exists $mech_params{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 20 | $mech_params{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 42 | $parent_params{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 76 | my $self = $class->SUPER::new(%parent_params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 76 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # Use the mech params now that we have a mech object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 76 | for my $param ( keys %mech_params ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 760 | $self->{$param} = $mech_params{$param}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 76 | $self->{page_stack} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 76 | ▶ | $self->env_proxy() unless $mech_params{noproxy}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # libwww-perl 5.800 (and before, I assume) has a problem where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # $ua->{proxy} can be undef and clone() doesn't handle it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 76 | ▶ | $self->{proxy} = {} unless defined $self->{proxy}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 76 | push( @{ $self->requests_redirectable }, 'POST' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 76 | $self->_reset_page(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 76 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # overriding LWP::UA's static method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | sub _agent { "WWW-Mechanize/$VERSION" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_agent: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 58 | my %known_agents = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 'Windows IE 6' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 'Windows Mozilla' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 'Mac Safari' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/85 (KHTML, like Gecko) Safari/85', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 'Mac Mozilla' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4a) Gecko/20030401', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 'Linux Mozilla' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 'Linux Konqueror' => 'Mozilla/5.0 (compatible; Konqueror/3; Linux)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | sub agent_alias { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
agent_alias: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | my $alias = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | ▶ | if ( defined $known_agents{$alias} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | return $self->agent( $known_agents{$alias} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | $self->warn(qq{Unknown agent alias "$alias"}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | return $self->agent(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | sub known_agent_aliases { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | my @aliases = sort keys %known_agents; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
known_agent_aliases: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | return @aliases; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | sub get { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 143 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 143 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 143 | $uri = $self->_uri_with_base($uri); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # It appears we are returning a super-class method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # but it in turn calls the request() method here in Mechanize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 143 | return $self->SUPER::get( $uri->as_string, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | sub post { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | $uri = $self->_uri_with_base($uri); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # It appears we are returning a super-class method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # but it in turn calls the request() method here in Mechanize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | return $self->SUPER::post( $uri->as_string, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | sub put { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $uri = $self->_uri_with_base($uri); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # It appears we are returning a super-class method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # but it in turn calls the request() method here in Mechanize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return $self->_SUPER_put( $uri->as_string, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # Added until LWP::UserAgent has it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | sub _SUPER_put { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | require HTTP::Request::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_SUPER_put: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my ( $self, @parameters ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my @suff = $self->_process_colonic_headers( \@parameters, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return $self->request( HTTP::Request::Common::PUT(@parameters), @suff ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub head { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
head: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | $uri = $self->_uri_with_base($uri); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # It appears we are returning a super-class method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # but it in turn calls the request() method here in Mechanize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | return $self->SUPER::head( $uri->as_string, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | sub delete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $uri = $self->_uri_with_base($uri); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # It appears we are returning a super-class method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # but it in turn calls the request() method here in Mechanize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | return $self->SUPER::delete( $uri->as_string, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | sub _uri_with_base { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 146 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uri_with_base: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 146 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 146 | ▶ | $uri = $uri->url if ref($uri) eq 'WWW::Mechanize::Link'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 146 | ▶ | $uri | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | = $self->base | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ? URI->new_abs( $uri, $self->base ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | : URI->new($uri); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 146 | return $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | sub reload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reload: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | ▶ | return unless my $req = $self->{req}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # LWP::UserAgent sets up a request_prepare handler that calls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # $self->cookie_jar->add_cookie_header($req) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # HTTP::Cookies::add_cookie_header always preserves existing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # cookies in a request object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # we pass an existing request to _make_request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # result: cookies will get repeated every time someone calls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # ->reload, sooner or later leading to a "request too big" from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # the server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # until https://rt.cpan.org/Public/Bug/Display.html?id=75897 is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # fixed, let's clear the cookies from the existing request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 3 | $req->remove_header('Cookie'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | return $self->_update_page( $req, $self->_make_request( $req, @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | sub back { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 29 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
back: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 29 | my $stack = $self->{page_stack}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 29 | ▶ | return unless $stack && @{$stack}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$stack and @{$stack;}
MC/DC100%2/2
$stack and @{$stack;}
$stack
@{$stack;}
Truth table100%3/3
A and B
A= $stackB= @{$stack;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 26 | my $popped = pop @{ $self->{page_stack} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 26 | my $req = $popped->{req}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 26 | my $res = $popped->{res}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 26 | $self->_update_page( $req, $res ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 26 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | sub clear_history { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_history: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | delete $self->{page_stack}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | sub history_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
history_count: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # If we don't have a "current" page, we certainly don't have any previous | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # ones. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 15 | ▶ | return 0 unless $self->{req} && $self->{res}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"req"} and $self->{"res"}
MC/DC50%1/2
$self->{"req"} and $self->{"res"}
$self->{"req"}
$self->{"res"}
Truth table66%2/3
A and B
A= $self->{"req"}B= $self->{"res"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 14 | my $stack = $self->{page_stack}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 14 | ▶ | return 1 unless $stack; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 13 | return 1 + @$stack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | sub history { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
history: called CC=6 SCAR=18.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 10 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 10 | ▶ | return undef unless $self->{req} && $self->{res}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"req"} and $self->{"res"}
MC/DC50%1/2
$self->{"req"} and $self->{"res"}
$self->{"req"}
$self->{"res"}
Truth table66%2/3
A and B
A= $self->{"req"}B= $self->{"res"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 9 | ▶ | if ( $n == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 8 | return { req => $self->{req}, res => $self->{res} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | my $stack = $self->{page_stack}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | ▶ | return undef unless $stack && @$stack >= $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$stack and @$stack >= $n
MC/DC0%0/2
$stack and @$stack >= $n
$stack
@$stack >= $n
Truth table33%1/3
A and B
A= $stackB= @$stack >= $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | return { req => $stack->[ -$n ]{req}, res => $stack->[ -$n ]{res} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | sub success { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 60 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
success: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 60 | ▶ | return $self->res && $self->res->is_success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->res && $self->res->is_success
MC/DC100%2/2
$self->res && $self->res->is_success
$self->res
$self->res->is_success
Truth table100%3/3
A && B
A= $self->resB= $self->res->is_success
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | sub uri { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 54 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 54 | ▶ | return $self->response ? $self->response->request->uri : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 123 | ▶ | sub res { my $self = shift; return $self->{res}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
res: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 119 | ▶ | sub response { my $self = shift; return $self->{res}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
response: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 11 | ▶ | sub status { my $self = shift; return $self->{status}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 748 | ▶ | sub ct { my $self = shift; return $self->{ct}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ct: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 8 | ▶ | sub content_type { my $self = shift; return $self->{ct}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 580 | ▶ | sub base { my $self = shift; return $self->{base}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | sub is_html { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 358 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_html: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 358 | ▶ | return defined $self->ct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
defined $self->ct && ($self->ct eq 'text/html' || $self->ct eq 'application/xhtml+xml')
$self->ct eq "text/html" or $self->ct eq "application/xhtml+xml"
MC/DC100%3/3
defined $self->ct && ($self->ct eq 'text/html' || $self->ct eq 'application/xhtml+xml')
defined $self->ct
$self->ct eq "text/html"
$self->ct eq "application/xhtml+xml"
Truth table100%4/4
A && B or C
A= defined $self->ctB= $self->ct eq "text/html"C= $self->ct eq "application/xhtml+xml"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | && ( $self->ct eq 'text/html' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | || $self->ct eq 'application/xhtml+xml' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | sub title { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 21 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
title: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 21 | ▶ | return unless $self->is_html; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 19 | ▶ | if ( not defined $self->{title} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 19 | require HTML::HeadParser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 19 | my $p = HTML::HeadParser->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 19 | $p->parse( $self->content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 19 | $self->{title} = $p->header('Title'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 19 | return $self->{title}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | sub redirects { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
redirects: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | return $self->response->redirects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | sub content { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 122 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 122 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 122 | my $content = $self->{content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 122 | ▶ | if ( delete $params{raw} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | my $res = $self->response(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 2 | ▶ | $content = $res->content() if $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | elsif ( delete $params{decoded_by_headers} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 2 | $content = $self->response()->decoded_content( charset => 'none' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | elsif ( my $charset = delete $params{charset} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 1 | $content = $self->response()->decoded_content( charset => $charset ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | elsif ( $self->is_html ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 107 | ▶ | if ( exists $params{base_href} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | ▶ | my $base_href = ( delete $params{base_href} ) || $self->base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $params{'base_href'} || $self->base
MC/DC0%0/2
delete $params{'base_href'} || $self->base
delete $params{'base_href'}
$self->base
Truth table66%2/3
A || B
A= delete $params{'base_href'}B= $self->base
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | $content =~ s/<head>/<head>\n<base href="$base_href">/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 107 | ▶ | if ( my $format = delete $params{format} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 2 | ▶ | if ( $format eq 'text' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | $content = $self->text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | $self->die(qq{Unknown "format" parameter "$format"}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 106 | $self->_check_unhandled_params(%params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 120 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | sub text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 3 | ▶ | if ( not defined $self->{text} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | ▶ | unless ( exists $INC{'HTML::TreeBuilder'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 2 | require HTML::TreeBuilder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | HTML::TreeBuilder->VERSION(5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 2 | HTML::TreeBuilder->import('-weak'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 2 | my $tree = HTML::TreeBuilder->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 2 | $tree->parse( $self->content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 2 | $tree->eof(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | $tree->elementify(); # just for safety | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 2 | $self->{text} = $tree->as_text(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 3 | return $self->{text}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | sub _check_unhandled_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 106 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_unhandled_params: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 106 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 106 | for my $cmd ( sort keys %params ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | $self->die(qq{Unknown named argument "$cmd"}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | sub links { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 87 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
links: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 87 | ▶ | $self->_extract_links() unless $self->{links}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 87 | ▶ | return @{ $self->{links} } if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | return $self->{links}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | sub follow_link { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 17 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
follow_link: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 17 | ▶ | $self->die(qq{Needs to get key-value pairs of parameters.}) if @_ % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 16 | my %params = ( n => 1, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 16 | ▶ | if ( $params{n} eq 'all' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | delete $params{n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | $self->warn(q{follow_link(n=>"all") is not valid}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 16 | my $link = $self->find_link(%params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 16 | ▶ | if ($link) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 11 | return $self->get( $link->url ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 5 | ▶ | if ( $self->{autocheck} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | $self->die('Link not found'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | sub find_link { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 77 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_link: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 77 | my %params = ( n => 1, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 77 | my $wantall = ( $params{n} eq 'all' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 77 | $self->_clean_keys( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | \%params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | qr/^(n|(text|url|url_abs|name|tag|id|class|rel)(_regex)?)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 77 | ▶ | my @links = $self->links or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 74 | my $nmatches = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 74 | my @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 74 | for my $link (@links) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 580 | ▶ | if ( _match_any_link_params( $link, \%params ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 117 | ▶ | if ($wantall) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 32 | push( @matches, $link ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 85 | ++$nmatches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 85 | ▶ | return $link if $nmatches >= $params{n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } # for @links | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 18 | ▶ | if ($wantall) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 9 | ▶ | return @matches if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 2 | return \@matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } # find_link | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # Used by find_links to check for matches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # The logic is such that ALL param criteria that are given must match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | sub _match_any_link_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 580 | ▶ | my $link = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match_any_link_params: called CC=46 SCAR=38.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 580 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # No conditions, anything matches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 580 | ▶ | return 1 unless keys %$p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 580 | ▶ | return if defined $p->{url} && !( $link->url eq $p->{url} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $p->{"url"} and not $link->url eq $p->{"url"}
MC/DC100%2/2
defined $p->{"url"} and not $link->url eq $p->{"url"}
defined $p->{"url"}
not $link->url eq $p->{"url"}
Truth table100%3/3
A and not(B)
A= defined $p->{"url"}B= not $link->url eq $p->{"url"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 487 | ▶ | return if defined $p->{url_regex} && !( $link->url =~ $p->{url_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $p->{"url_regex"} and not $link->url =~ /$p->{"url_regex"}/
MC/DC100%2/2
defined $p->{"url_regex"} and not $link->url =~ /$p->{"url_regex"}/
defined $p->{"url_regex"}
not $link->url =~ /$p->{"url_regex"}/
Truth table100%3/3
A and not(B)
A= defined $p->{"url_regex"}B= not $link->url =~ /$p->{"url_regex"}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 424 | ▶ | return if defined $p->{url_abs} && !( $link->url_abs eq $p->{url_abs} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $p->{"url_abs"} and not $link->url_abs eq $p->{"url_abs"}
MC/DC50%1/2
defined $p->{"url_abs"} and not $link->url_abs eq $p->{"url_abs"}
defined $p->{"url_abs"}
not $link->url_abs eq $p->{"url_abs"}
Truth table66%2/3
A and not(B)
A= defined $p->{"url_abs"}B= not $link->url_abs eq $p->{"url_abs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | if defined $p->{url_abs_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 398 | ▶ | && !( $link->url_abs =~ $p->{url_abs_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $p->{"url_abs_regex"} and not $link->url_abs =~ /$p->{"url_abs_regex"}/
MC/DC100%2/2
defined $p->{"url_abs_regex"} and not $link->url_abs =~ /$p->{"url_abs_regex"}/
defined $p->{"url_abs_regex"}
not $link->url_abs =~ /$p->{"url_abs_regex"}/
Truth table100%3/3
A and not(B)
A= defined $p->{"url_abs_regex"}B= not $link->url_abs =~ /$p->{"url_abs_regex"}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | if defined $p->{text} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 374 | ▶ | && !( defined( $link->text ) && $link->text eq $p->{text} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $p->{"text"} and not defined $link->text && $link->text eq $p->{"text"}
defined $link->text && $link->text eq $p->{'text'}
MC/DC100%3/3
defined $p->{"text"} and not defined $link->text && $link->text eq $p->{"text"}
defined $p->{"text"}
defined $link->text
$link->text eq $p->{'text'}
Truth table100%4/4
A and not(B && C)
A= defined $p->{"text"}B= defined $link->textC= $link->text eq $p->{'text'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | if defined $p->{text_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 307 | ▶ | && !( defined( $link->text ) && $link->text =~ $p->{text_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $p->{"text_regex"} and not defined $link->text && $link->text =~ /$p->{"text_regex"}/
defined $link->text && $link->text =~ /$p->{'text_regex'}/
MC/DC100%3/3
defined $p->{"text_regex"} and not defined $link->text && $link->text =~ /$p->{"text_regex"}/
defined $p->{"text_regex"}
defined $link->text
$link->text =~ /$p->{'text_regex'}/
Truth table100%4/4
A and not(B && C)
A= defined $p->{"text_regex"}B= defined $link->textC= $link->text =~ /$p->{'text_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | if defined $p->{name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 162 | ▶ | && !( defined( $link->name ) && $link->name eq $p->{name} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"name"} and not defined $link->name && $link->name eq $p->{"name"}
defined $link->name && $link->name eq $p->{'name'}
MC/DC66%2/3
defined $p->{"name"} and not defined $link->name && $link->name eq $p->{"name"}
defined $p->{"name"}
defined $link->name
$link->name eq $p->{'name'}
Truth table75%3/4
A and not(B && C)
A= defined $p->{"name"}B= defined $link->nameC= $link->name eq $p->{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | if defined $p->{name_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 153 | ▶ | && !( defined( $link->name ) && $link->name =~ $p->{name_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $p->{"name_regex"} and not defined $link->name && $link->name =~ /$p->{"name_regex"}/
defined $link->name && $link->name =~ /$p->{'name_regex'}/
MC/DC100%3/3
defined $p->{"name_regex"} and not defined $link->name && $link->name =~ /$p->{"name_regex"}/
defined $p->{"name_regex"}
defined $link->name
$link->name =~ /$p->{'name_regex'}/
Truth table100%4/4
A and not(B && C)
A= defined $p->{"name_regex"}B= defined $link->nameC= $link->name =~ /$p->{'name_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 138 | ▶ | return if defined $p->{tag} && !( $link->tag && $link->tag eq $p->{tag} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"tag"} and not $link->tag && $link->tag eq $p->{"tag"}
$link->tag && $link->tag eq $p->{'tag'}
MC/DC66%2/3
defined $p->{"tag"} and not $link->tag && $link->tag eq $p->{"tag"}
defined $p->{"tag"}
$link->tag
$link->tag eq $p->{'tag'}
Truth table75%3/4
A and not(B && C)
A= defined $p->{"tag"}B= $link->tagC= $link->tag eq $p->{'tag'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | if defined $p->{tag_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 134 | ▶ | && !( $link->tag && $link->tag =~ $p->{tag_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"tag_regex"} and not $link->tag && $link->tag =~ /$p->{"tag_regex"}/
$link->tag && $link->tag =~ /$p->{'tag_regex'}/
MC/DC66%2/3
defined $p->{"tag_regex"} and not $link->tag && $link->tag =~ /$p->{"tag_regex"}/
defined $p->{"tag_regex"}
$link->tag
$link->tag =~ /$p->{'tag_regex'}/
Truth table75%3/4
A and not(B && C)
A= defined $p->{"tag_regex"}B= $link->tagC= $link->tag =~ /$p->{'tag_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | if defined $p->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 130 | ▶ | && !( $link->attrs->{id} && $link->attrs->{id} eq $p->{id} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"id"} and not $link->attrs->{"id"} && $link->attrs->{"id"} eq $p->{"id"}
$link->attrs->{'id'} && $link->attrs->{'id'} eq $p->{'id'}
MC/DC66%2/3
defined $p->{"id"} and not $link->attrs->{"id"} && $link->attrs->{"id"} eq $p->{"id"}
defined $p->{"id"}
$link->attrs->{'id'}
$link->attrs->{'id'} eq $p->{'id'}
Truth table75%3/4
A and not(B && C)
A= defined $p->{"id"}B= $link->attrs->{'id'}C= $link->attrs->{'id'} eq $p->{'id'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | if defined $p->{id_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 127 | ▶ | && !( $link->attrs->{id} && $link->attrs->{id} =~ $p->{id_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"id_regex"} and not $link->attrs->{"id"} && $link->attrs->{"id"} =~ /$p->{"id_regex"}/
$link->attrs->{'id'} && $link->attrs->{'id'} =~ /$p->{'id_regex'}/
MC/DC66%2/3
defined $p->{"id_regex"} and not $link->attrs->{"id"} && $link->attrs->{"id"} =~ /$p->{"id_regex"}/
defined $p->{"id_regex"}
$link->attrs->{'id'}
$link->attrs->{'id'} =~ /$p->{'id_regex'}/
Truth table75%3/4
A and not(B && C)
A= defined $p->{"id_regex"}B= $link->attrs->{'id'}C= $link->attrs->{'id'} =~ /$p->{'id_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | if defined $p->{class} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 124 | ▶ | && !( $link->attrs->{class} && $link->attrs->{class} eq $p->{class} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"class"} and not $link->attrs->{"class"} && $link->attrs->{"class"} eq $p->{"class"}
$link->attrs->{'class'} && $link->attrs->{'class'} eq $p->{'class'}
MC/DC66%2/3
defined $p->{"class"} and not $link->attrs->{"class"} && $link->attrs->{"class"} eq $p->{"class"}
defined $p->{"class"}
$link->attrs->{'class'}
$link->attrs->{'class'} eq $p->{'class'}
Truth table75%3/4
A and not(B && C)
A= defined $p->{"class"}B= $link->attrs->{'class'}C= $link->attrs->{'class'} eq $p->{'class'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | if defined $p->{class_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | && !( $link->attrs->{class} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 123 | ▶ | && $link->attrs->{class} =~ $p->{class_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"class_regex"} and not $link->attrs->{"class"} && $link->attrs->{"class"} =~ /$p->{"class_regex"}/
$link->attrs->{'class'} && $link->attrs->{'class'} =~ /$p->{'class_regex'}/
MC/DC66%2/3
defined $p->{"class_regex"} and not $link->attrs->{"class"} && $link->attrs->{"class"} =~ /$p->{"class_regex"}/
defined $p->{"class_regex"}
$link->attrs->{'class'}
$link->attrs->{'class'} =~ /$p->{'class_regex'}/
Truth table75%3/4
A and not(B && C)
A= defined $p->{"class_regex"}B= $link->attrs->{'class'}C= $link->attrs->{'class'} =~ /$p->{'class_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | if defined $p->{rel} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 122 | ▶ | && !( $link->attrs->{rel} && $link->attrs->{rel} eq $p->{rel} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $p->{"rel"} and not $link->attrs->{"rel"} && $link->attrs->{"rel"} eq $p->{"rel"}
$link->attrs->{'rel'} && $link->attrs->{'rel'} eq $p->{'rel'}
MC/DC100%3/3
defined $p->{"rel"} and not $link->attrs->{"rel"} && $link->attrs->{"rel"} eq $p->{"rel"}
defined $p->{"rel"}
$link->attrs->{'rel'}
$link->attrs->{'rel'} eq $p->{'rel'}
Truth table100%4/4
A and not(B && C)
A= defined $p->{"rel"}B= $link->attrs->{'rel'}C= $link->attrs->{'rel'} eq $p->{'rel'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | if defined $p->{rel_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 119 | ▶ | && !( $link->attrs->{rel} && $link->attrs->{rel} =~ $p->{rel_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"rel_regex"} and not $link->attrs->{"rel"} && $link->attrs->{"rel"} =~ /$p->{"rel_regex"}/
$link->attrs->{'rel'} && $link->attrs->{'rel'} =~ /$p->{'rel_regex'}/
MC/DC66%2/3
defined $p->{"rel_regex"} and not $link->attrs->{"rel"} && $link->attrs->{"rel"} =~ /$p->{"rel_regex"}/
defined $p->{"rel_regex"}
$link->attrs->{'rel'}
$link->attrs->{'rel'} =~ /$p->{'rel_regex'}/
Truth table75%3/4
A and not(B && C)
A= defined $p->{"rel_regex"}B= $link->attrs->{'rel'}C= $link->attrs->{'rel'} =~ /$p->{'rel_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | # Success: everything that was defined passed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 117 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # Cleans the %params parameter for the find_link and find_image methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | sub _clean_keys { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 127 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_keys: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 127 | my $params = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 127 | my $rx_keyname = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 127 | for my $key ( keys %$params ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 241 | my $val = $params->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 241 | ▶ | if ( $key !~ qr/$rx_keyname/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 5 | $self->warn(qq{Unknown link-finding parameter "$key"}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 5 | delete $params->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 236 | my $key_regex = ( $key =~ /_regex$/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 236 | my $val_regex = ( ref($val) eq 'Regexp' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 236 | ▶ | if ($key_regex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 49 | ▶ | if ( !$val_regex ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 6 | $self->warn(qq{$val passed as $key is not a regex}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 6 | delete $params->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 187 | ▶ | if ($val_regex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 5 | $self->warn(qq{$val passed as '$key' is a regex}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 5 | delete $params->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 182 | ▶ | if ( $val =~ /^\s|\s$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 5 | $self->warn(qq{'$val' is space-padded and cannot succeed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 5 | delete $params->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } # for keys %params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 127 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } # _clean_keys() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | sub find_all_links { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_all_links: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 9 | return $self->find_link( @_, n => 'all' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | sub find_all_inputs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_all_inputs: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 8 | my %criteria = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 8 | ▶ | my $form = $self->current_form() or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 8 | my @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 8 | foreach my $input ( $form->inputs ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | { # check every pattern for a match on the current hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 34 | my $matched = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 34 | foreach my $criterion ( sort keys %criteria ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | { # Sort so we're deterministic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 22 | my $field = $criterion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 22 | my $is_regex = ( $field =~ s/(?:_regex)$// ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 22 | my $what = $input->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | $matched = defined($what) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | $is_regex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | ? ( $what =~ $criteria{$criterion} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 22 | ▶ | : ( $what eq $criteria{$criterion} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $what && ($is_regex ? $what =~ /$criteria{$criterion}/ : $what eq $criteria{$criterion})
MC/DC50%1/2
defined $what && ($is_regex ? $what =~ /$criteria{$criterion}/ : $what eq $criteria{$criterion})
defined $what
($is_regex ? $what =~ /$criteria{$criterion}/ : $what eq $criteria{$criterion})
Truth table66%2/3
A && B
A= defined $whatB= ($is_regex ? $what =~ /$criteria{$criterion}/ : $what eq $criteria{$criterion})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 22 | ▶ | last if !$matched; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 34 | ▶ | push @found, $input if $matched; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 8 | return @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | sub find_all_submits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_all_submits: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 2 | return $self->find_all_inputs( @_, type_regex => qr/^(submit|image)$/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | sub images { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 58 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
images: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 58 | ▶ | $self->_extract_images() unless $self->{images}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 58 | ▶ | return @{ $self->{images} } if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 1 | return $self->{images}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | sub find_image { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 50 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_image: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 50 | my %params = ( n => 1, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 50 | my $wantall = ( $params{n} eq 'all' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 50 | $self->_clean_keys( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | \%params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | qr/^(?:n|(?:alt|url|url_abs|tag|id|class)(?:_regex)?)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 50 | ▶ | my @images = $self->images or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 50 | my $nmatches = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 50 | my @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 50 | for my $image (@images) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 429 | ▶ | if ( _match_any_image_params( $image, \%params ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 87 | ▶ | if ($wantall) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 66 | push( @matches, $image ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 21 | ++$nmatches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 21 | ▶ | return $image if $nmatches >= $params{n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } # for @images | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 30 | ▶ | if ($wantall) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 18 | ▶ | return @matches if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 1 | return \@matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # Used by find_images to check for matches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # The logic is such that ALL param criteria that are given must match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | sub _match_any_image_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 429 | ▶ | my $image = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match_any_image_params: called CC=42 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 429 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | # No conditions, anything matches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 429 | ▶ | return 1 unless keys %$p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | if defined $p->{url} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 429 | ▶ | && !( defined( $image->url ) && $image->url eq $p->{url} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $p->{"url"} and not defined $image->url && $image->url eq $p->{"url"}
defined $image->url && $image->url eq $p->{'url'}
MC/DC100%3/3
defined $p->{"url"} and not defined $image->url && $image->url eq $p->{"url"}
defined $p->{"url"}
defined $image->url
$image->url eq $p->{'url'}
Truth table100%4/4
A and not(B && C)
A= defined $p->{"url"}B= defined $image->urlC= $image->url eq $p->{'url'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | if defined $p->{url_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 387 | ▶ | && !( defined( $image->url ) && $image->url =~ $p->{url_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $p->{"url_regex"} and not defined $image->url && $image->url =~ /$p->{"url_regex"}/
defined $image->url && $image->url =~ /$p->{'url_regex'}/
MC/DC100%3/3
defined $p->{"url_regex"} and not defined $image->url && $image->url =~ /$p->{"url_regex"}/
defined $p->{"url_regex"}
defined $image->url
$image->url =~ /$p->{'url_regex'}/
Truth table100%4/4
A and not(B && C)
A= defined $p->{"url_regex"}B= defined $image->urlC= $image->url =~ /$p->{'url_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | if defined $p->{url_abs} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | && !( defined( $image->url_abs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 354 | ▶ | && $image->url_abs eq $p->{url_abs} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"url_abs"} and not defined $image->url_abs && $image->url_abs eq $p->{"url_abs"}
defined $image->url_abs && $image->url_abs eq $p->{'url_abs'}
MC/DC66%2/3
defined $p->{"url_abs"} and not defined $image->url_abs && $image->url_abs eq $p->{"url_abs"}
defined $p->{"url_abs"}
defined $image->url_abs
$image->url_abs eq $p->{'url_abs'}
Truth table75%3/4
A and not(B && C)
A= defined $p->{"url_abs"}B= defined $image->url_absC= $image->url_abs eq $p->{'url_abs'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | if defined $p->{url_abs_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | && !( defined( $image->url_abs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 324 | ▶ | && $image->url_abs =~ $p->{url_abs_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"url_abs_regex"} and not defined $image->url_abs && $image->url_abs =~ /$p->{"url_abs_regex"}/
defined $image->url_abs && $image->url_abs =~ /$p->{'url_abs_regex'}/
MC/DC66%2/3
defined $p->{"url_abs_regex"} and not defined $image->url_abs && $image->url_abs =~ /$p->{"url_abs_regex"}/
defined $p->{"url_abs_regex"}
defined $image->url_abs
$image->url_abs =~ /$p->{'url_abs_regex'}/
Truth table75%3/4
A and not(B && C)
A= defined $p->{"url_abs_regex"}B= defined $image->url_absC= $image->url_abs =~ /$p->{'url_abs_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | if defined $p->{alt} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 299 | ▶ | && !( defined( $image->alt ) && $image->alt eq $p->{alt} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $p->{"alt"} and not defined $image->alt && $image->alt eq $p->{"alt"}
defined $image->alt && $image->alt eq $p->{'alt'}
MC/DC100%3/3
defined $p->{"alt"} and not defined $image->alt && $image->alt eq $p->{"alt"}
defined $p->{"alt"}
defined $image->alt
$image->alt eq $p->{'alt'}
Truth table100%4/4
A and not(B && C)
A= defined $p->{"alt"}B= defined $image->altC= $image->alt eq $p->{'alt'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | if defined $p->{alt_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 275 | ▶ | && !( defined( $image->alt ) && $image->alt =~ $p->{alt_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $p->{"alt_regex"} and not defined $image->alt && $image->alt =~ /$p->{"alt_regex"}/
defined $image->alt && $image->alt =~ /$p->{'alt_regex'}/
MC/DC100%3/3
defined $p->{"alt_regex"} and not defined $image->alt && $image->alt =~ /$p->{"alt_regex"}/
defined $p->{"alt_regex"}
defined $image->alt
$image->alt =~ /$p->{'alt_regex'}/
Truth table100%4/4
A and not(B && C)
A= defined $p->{"alt_regex"}B= defined $image->altC= $image->alt =~ /$p->{'alt_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 251 | ▶ | if defined $p->{tag} && !( $image->tag && $image->tag eq $p->{tag} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"tag"} and not $image->tag && $image->tag eq $p->{"tag"}
$image->tag && $image->tag eq $p->{'tag'}
MC/DC66%2/3
defined $p->{"tag"} and not $image->tag && $image->tag eq $p->{"tag"}
defined $p->{"tag"}
$image->tag
$image->tag eq $p->{'tag'}
Truth table75%3/4
A and not(B && C)
A= defined $p->{"tag"}B= $image->tagC= $image->tag eq $p->{'tag'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | if defined $p->{tag_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 212 | ▶ | && !( $image->tag && $image->tag =~ $p->{tag_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $p->{"tag_regex"} and not $image->tag && $image->tag =~ /$p->{"tag_regex"}/
$image->tag && $image->tag =~ /$p->{'tag_regex'}/
MC/DC66%2/3
defined $p->{"tag_regex"} and not $image->tag && $image->tag =~ /$p->{"tag_regex"}/
defined $p->{"tag_regex"}
$image->tag
$image->tag =~ /$p->{'tag_regex'}/
Truth table75%3/4
A and not(B && C)
A= defined $p->{"tag_regex"}B= $image->tagC= $image->tag =~ /$p->{'tag_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | if defined $p->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | && !( $image->attrs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | && $image->attrs->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 196 | ▶ | && $image->attrs->{id} eq $p->{id} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
defined $p->{"id"} and not $image->attrs && $image->attrs->{"id"} && $image->attrs->{"id"} eq $p->{"id"}
$image->attrs && $image->attrs->{'id'} && $image->attrs->{'id'} eq $p->{'id'}
$image->attrs and $image->attrs->{"id"}
MC/DC100%4/4
defined $p->{"id"} and not $image->attrs && $image->attrs->{"id"} && $image->attrs->{"id"} eq $p->{"id"}
defined $p->{"id"}
$image->attrs
$image->attrs->{"id"}
$image->attrs->{'id'} eq $p->{'id'}
Truth table100%5/5
A and not(B and C && D)
A= defined $p->{"id"}B= $image->attrsC= $image->attrs->{"id"}D= $image->attrs->{'id'} eq $p->{'id'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | if defined $p->{id_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | && !( $image->attrs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | && $image->attrs->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 169 | ▶ | && $image->attrs->{id} =~ $p->{id_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
defined $p->{"id_regex"} and not $image->attrs && $image->attrs->{"id"} && $image->attrs->{"id"} =~ /$p->{"id_regex"}/
$image->attrs && $image->attrs->{'id'} && $image->attrs->{'id'} =~ /$p->{'id_regex'}/
$image->attrs and $image->attrs->{"id"}
MC/DC100%4/4
defined $p->{"id_regex"} and not $image->attrs && $image->attrs->{"id"} && $image->attrs->{"id"} =~ /$p->{"id_regex"}/
defined $p->{"id_regex"}
$image->attrs
$image->attrs->{"id"}
$image->attrs->{'id'} =~ /$p->{'id_regex'}/
Truth table100%5/5
A and not(B and C && D)
A= defined $p->{"id_regex"}B= $image->attrsC= $image->attrs->{"id"}D= $image->attrs->{'id'} =~ /$p->{'id_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | if defined $p->{class} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | && !( $image->attrs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | && $image->attrs->{class} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 143 | ▶ | && $image->attrs->{class} eq $p->{class} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
defined $p->{"class"} and not $image->attrs && $image->attrs->{"class"} && $image->attrs->{"class"} eq $p->{"class"}
$image->attrs && $image->attrs->{'class'} && $image->attrs->{'class'} eq $p->{'class'}
$image->attrs and $image->attrs->{"class"}
MC/DC100%4/4
defined $p->{"class"} and not $image->attrs && $image->attrs->{"class"} && $image->attrs->{"class"} eq $p->{"class"}
defined $p->{"class"}
$image->attrs
$image->attrs->{"class"}
$image->attrs->{'class'} eq $p->{'class'}
Truth table100%5/5
A and not(B and C && D)
A= defined $p->{"class"}B= $image->attrsC= $image->attrs->{"class"}D= $image->attrs->{'class'} eq $p->{'class'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | if defined $p->{class_regex} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | && !( $image->attrs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | && $image->attrs->{class} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 116 | ▶ | && $image->attrs->{class} =~ $p->{class_regex} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
defined $p->{"class_regex"} and not $image->attrs && $image->attrs->{"class"} && $image->attrs->{"class"} =~ /$p->{"class_regex"}/
$image->attrs && $image->attrs->{'class'} && $image->attrs->{'class'} =~ /$p->{'class_regex'}/
$image->attrs and $image->attrs->{"class"}
MC/DC100%4/4
defined $p->{"class_regex"} and not $image->attrs && $image->attrs->{"class"} && $image->attrs->{"class"} =~ /$p->{"class_regex"}/
defined $p->{"class_regex"}
$image->attrs
$image->attrs->{"class"}
$image->attrs->{'class'} =~ /$p->{'class_regex'}/
Truth table100%5/5
A and not(B and C && D)
A= defined $p->{"class_regex"}B= $image->attrsC= $image->attrs->{"class"}D= $image->attrs->{'class'} =~ /$p->{'class_regex'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # Success: everything that was defined passed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 87 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | sub find_all_images { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 18 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_all_images: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 18 | return $self->find_image( @_, n => 'all' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | sub forms { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 161 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forms: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 161 | ▶ | $self->_extract_forms() unless $self->{forms}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 159 | ▶ | return @{ $self->{forms} } if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 91 | return $self->{forms}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | sub current_form { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 167 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_form: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 167 | ▶ | if ( !$self->{current_form} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 31 | $self->form_number(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 166 | return $self->{current_form}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | sub form_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 53 | ▶ | my ( $self, $form ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form_number: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | # XXX Should we die if no $form is defined? Same question for form_name() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 53 | my $forms = $self->forms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 51 | ▶ | if ( $forms->[ $form - 1 ] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 49 | $self->{current_form} = $forms->[ $form - 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | return wantarray | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | ? ( $self->{current_form}, $form ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 49 | ▶ | : $self->{current_form}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 2 | ▶ | return wantarray ? () : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | sub form_action { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 3 | ▶ | my ( $self, $action ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form_action: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 3 | my $temp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | my @matches = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 3 | ▶ | defined( $temp = $_->action ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | and ( $temp =~ m/$action/msx ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } $self->forms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 3 | my $nmatches = @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 3 | ▶ | if ( $nmatches > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 2 | ▶ | if ( $nmatches > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 1 | $self->warn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | "There are $nmatches forms with action matching $action. The first one was used." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 2 | return $self->{current_form} = $matches[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | sub form_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 8 | ▶ | my ( $self, $name, $args ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form_name: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 8 | ▶ | return $self->form_with( name => $name, $args || () ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args || ()
MC/DC0%0/2
$args || ()
$args
()
Truth table66%2/3
A || B
A= $argsB= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | sub form_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 6 | ▶ | my ( $self, $formid, $args ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form_id: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 6 | ▶ | defined( my $form = $self->form_with( id => $formid, $args || () ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args || ()
MC/DC0%0/2
$args || ()
$args
()
Truth table66%2/3
A || B
A= $argsB= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | or $self->warn(qq{ There is no form with ID "$formid"}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 6 | return $form; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | sub all_forms_with_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 21 | ▶ | my ( $self, @fields ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_forms_with_fields: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 21 | ▶ | $self->die('no fields provided') unless scalar @fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 20 | my @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 20 | FORMS: for my $form ( @{ $self->forms } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 153 | my @fields_in_form = $form->param(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 153 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 170 | ▶ | next FORMS unless grep { $_ eq $field } @fields_in_form; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 29 | push @matches, $form; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 20 | return @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | sub form_with_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 12 | ▶ | my ( $self, @fields ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form_with_fields: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 12 | ▶ | $self->die('no fields provided') unless scalar @fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 10 | my $nth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 10 | ▶ | if ( @fields > 1 && ref $fields[-1] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@fields > 1 and ref $fields[-1] eq "HASH"
MC/DC100%2/2
@fields > 1 and ref $fields[-1] eq "HASH"
@fields > 1
ref $fields[-1] eq "HASH"
Truth table100%3/3
A and B
A= @fields > 1B= ref $fields[-1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 3 | $nth = ( pop @fields )->{n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 10 | my @matches = $self->all_forms_with_fields(@fields); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 10 | ▶ | if ($nth) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 3 | ▶ | @matches = ( @matches >= $nth ) ? ( $matches[ $nth - 1 ] ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 10 | my $nmatches = @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 10 | ▶ | if ( $nmatches > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 9 | ▶ | if ( $nmatches > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 4 | $self->warn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | "There are $nmatches forms with the named fields. The first one was used." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 9 | return $self->{current_form} = $matches[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 1 | ▶ | $self->warn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | $nth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | ? qq{There is no match \#$nth form with the requested fields} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | : qq{There is no form with the requested fields} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | sub all_forms_with { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 42 | ▶ | my ( $self, %spec ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_forms_with: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 42 | my $action = delete $spec{action}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 42 | ▶ | my @forms = grep { !$action || $_->action eq $action } $self->forms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 42 | foreach my $attr ( keys %spec ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 45 | ▶ | @forms = grep _equal( $spec{$attr}, $_->attr($attr) ), @forms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 37 | return @forms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | sub form_with { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 20 | ▶ | my ( $self, @args ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form_with: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 20 | ▶ | return if not $self->forms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | # Determine if we should return the nth instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 20 | my $nth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 20 | ▶ | if ( @args % 2 && ref $args[-1] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@args % 2 and ref $args[-1] eq "HASH"
MC/DC50%1/2
@args % 2 and ref $args[-1] eq "HASH"
@args % 2
ref $args[-1] eq "HASH"
Truth table66%2/3
A and B
A= @args % 2B= ref $args[-1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 7 | $nth = ( pop @args )->{n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 20 | my %spec = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 20 | my @forms = $self->all_forms_with(%spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 20 | ▶ | if ($nth) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 7 | ▶ | @forms = ( @forms >= $nth ) ? $forms[ $nth - 1 ] : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 20 | ▶ | if ( @forms > 1 ) { # Warn if several forms matched. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | # For ->form_with( method => 'POST', action => '', id => undef ) we get: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | # >>There are 2 forms with empty action and no id and method "POST". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | # The first one was used.<< | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | $self->warn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 'There are ' . @forms . ' forms ' . ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | keys %spec # explain search criteria if there were any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | ? 'with ' . join( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | ' and ', # "with ... and ... and ..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 3 | ▶ | unless ( defined $spec{$_} ) { # case $attr => undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 1 | qq{no $_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | elsif ( $spec{$_} eq q{} ) { # case $attr=> '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 1 | qq{empty $_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | else { # case $attr => $value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 3 | qq{$_ "$spec{$_}"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } # case $attr => undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | sort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | keys %spec # sort keys to get deterministic messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | : q{} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | . '. The first one was used.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 20 | return $self->{current_form} = $forms[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | # NOT an object method! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | # Expects two values and returns true only when either | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # both are defined and eq(ual) or when both are not defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | sub _equal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 265 | ▶ | my ( $x, $y ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_equal: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 265 | ▶ | defined $x ? defined $y && $x eq $y : !defined $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $y and $x eq $y
MC/DC100%2/2
defined $y and $x eq $y
defined $y
$x eq $y
Truth table100%3/3
A and B
A= defined $yB= $x eq $y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | sub field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 49 | ▶ | my ( $self, $name, $value, $number ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
field: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 49 | ▶ | $number ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$number ||= 1
MC/DC100%1/1
$number ||= 1
$number
Truth table100%2/2
A
A= $number
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 49 | my $form = $self->current_form(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 49 | ▶ | if ( $number > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | $form->find_input( $name, undef, $number )->value($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 49 | ▶ | if ( ref($value) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 11 | my $input = $form->find_input($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 11 | ▶ | if ( $input->type eq 'file' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 10 | $input->file( shift @$value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 10 | $input->filename( shift @$value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 10 | $input->headers(@$value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 1 | $form->param( $name, $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 38 | $form->value( $name => $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | sub select { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 13 | ▶ | my ( $self, $name, $value, $number ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
select: called CC=16 SCAR=29.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 13 | ▶ | $number ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$number ||= 1
MC/DC100%1/1
$number ||= 1
$number
Truth table100%2/2
A
A= $number
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 13 | my $form = $self->current_form(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 13 | my $input = $form->find_input( $name, undef, $number ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 13 | ▶ | if ( !$input ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 1 | $self->warn(qq{Input "$name" not found}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 12 | ▶ | if ( $input->type ne 'option' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | $self->warn(qq{Input "$name" is not type "select"}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | # For $mech->select($name, {n => 3}) or $mech->select($name, {n => [2,4]}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | # transform the 'n' number(s) into value(s) and put it in $value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 12 | ▶ | if ( ref($value) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 4 | for ( keys %$value ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 4 | ▶ | $self->warn(qq{Unknown select value parameter "$_"}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | unless $_ eq 'n'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 4 | ▶ | if ( defined( $value->{n} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 4 | my @inputs = $form->find_input( $name, 'option' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 4 | my @values = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | # distinguish between multiple and non-multiple selects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | # (see INPUTS section of `perldoc HTML::Form`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 4 | ▶ | if ( @inputs == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 2 | @values = $inputs[0]->possible_values(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 2 | foreach my $input (@inputs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 8 | my @possible = $input->possible_values(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 8 | push @values, pop @possible; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 4 | my $n = $value->{n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 4 | ▶ | if ( ref($n) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 2 | $value = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 2 | for (@$n) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 4 | ▶ | unless (/^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | $self->warn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | qq{"n" value "$_" is not a positive integer}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 4 | push @$value, $values[ $_ - 1 ]; # might be undef | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | ▶ | elsif ( !ref($n) && $n =~ /^\d+$/ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
not ref $n and $n =~ /^\d+$/
MC/DC0%0/2
not ref $n and $n =~ /^\d+$/
not ref $n
$n =~ /^\d+$/
Truth table33%1/3
not(A) and B
A= not ref $nB= $n =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 2 | $value = $values[ $n - 1 ]; # might be undef | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | $self->warn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | '"n" value is not a positive integer or an array ref'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | $self->warn('Hash value is invalid'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | } # hashref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 12 | ▶ | if ( ref($value) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 4 | $form->param( $name, $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 8 | $form->find_input( $name, undef, $number )->value($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | sub set_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 27 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_fields: called CC=11 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 27 | my %fields = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 27 | ▶ | my $form = $self->current_form or $self->die('No form defined'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | FIELD: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 27 | for my $field ( keys %fields ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 32 | my $value = $fields{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 32 | my $number = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 32 | ▶ | if ( ref $value eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 9 | ▶ | my $input = $form->find_input($field) or next FIELD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | # Honor &submit_form's documentation, that says that a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | # "file" input's value can be in the form of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | # "[[$filepath, $filename], 1]". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 8 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$input->type ne "file" or $input->type eq "file" and ref $value->[0] eq "ARRAY"
$input->type eq "file" and ref $value->[0] eq "ARRAY"
MC/DC66%2/3
$input->type ne "file" or $input->type eq "file" and ref $value->[0] eq "ARRAY"
$input->type ne "file"
$input->type eq "file"
ref $value->[0] eq "ARRAY"
Truth table75%3/4
A or B and C
A= $input->type ne "file"B= $input->type eq "file"C= ref $value->[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | $input->type ne 'file' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | || ( $input->type eq 'file' && ref( $value->[0] ) eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 4 | ( $value, $number ) = ( $value->[0], $value->[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 23 | ▶ | if ( ref $value eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 2 | my $input = $form->find_input($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 2 | ▶ | if ( not defined int $$value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | "Only references to integers are supported. Using 0."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | $$value = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 2 | my @possible_values = $input->possible_values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 2 | ▶ | if ( $#possible_values < $$value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | "Not enough options for $field to select index $$value"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | next FIELD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 2 | $value = $possible_values[$$value]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 31 | $self->field( $field, $value, $number ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | sub set_visible { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_visible: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 2 | my $form = $self->current_form; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 2 | my @inputs = $form->inputs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 2 | my $num_set = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 2 | for my $value (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | # Handle type/value pairs an arrayref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 4 | ▶ | if ( ref $value eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 1 | my ( $type, $value ) = @$value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 1 | ▶ | while ( my $input = shift @inputs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 3 | ▶ | next if $input->type eq 'hidden'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 3 | ▶ | if ( $input->type eq $type ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 1 | $input->value($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 1 | $num_set++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | } # while | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | # by default, it's a value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 3 | ▶ | while ( my $input = shift @inputs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 3 | ▶ | next if $input->type eq 'hidden'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 3 | $input->value($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 3 | $num_set++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } # while | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | } # for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 2 | return $num_set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | } # set_visible() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | sub tick { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tick: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 5 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 5 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 5 | ▶ | my $set = @_ ? shift : 1; # default to 1 if not passed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | # loop though all the inputs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 5 | my $index = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 5 | ▶ | while ( my $input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | = $self->current_form->find_input( $name, 'checkbox', $index ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | # Sometimes the HTML is malformed and there is no value for the check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | # box, so we just return if the value passed is an empty string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | # (and the form input is found) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 5 | ▶ | if ( $value eq q{} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 1 | ▶ | $input->value( $set ? $value : undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | # Can't guarantee that the first element will be undef and the second | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | # element will be the right name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 4 | foreach my $val ( $input->possible_values() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 8 | ▶ | next unless defined $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 4 | ▶ | if ( $val eq $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 3 | ▶ | $input->value( $set ? $value : undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | # move onto the next input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 1 | $index++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | } # while | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | # got this far? Didn't find anything | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 1 | $self->die(qq{No checkbox "$name" for value "$value" in form}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } # tick() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | sub untick { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 1 | ▶ | shift->tick( shift, shift, undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
untick: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | sub value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 16 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 16 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 16 | ▶ | my $number = shift || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 1
MC/DC100%1/1
shift() || 1
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 16 | my $form = $self->current_form; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 16 | ▶ | if ( $number > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 1 | return $form->find_input( $name, undef, $number )->value(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 15 | return $form->value($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | } # value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | sub click { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 2 | ▶ | my ( $self, $button, $x, $y ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
click: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 2 | ▶ | for ( $x, $y ) { $_ = 1 unless defined; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 2 | my $request = $self->current_form->click( $button, $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 2 | return $self->request($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | sub click_button { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
click_button: called CC=16 SCAR=27.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 15 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 15 | for ( keys %args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 18 | ▶ | if ( !/^(number|name|value|id|input|x|y)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | $self->warn(qq{Unknown click_button parameter "$_"}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 15 | my %exclusive_options = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | id => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | input => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | name => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | number => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | value => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | my @present_exclusive_options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 15 | ▶ | = map { $_ || () } @exclusive_options{ keys %args }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 15 | ▶ | if ( scalar @present_exclusive_options > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 1 | $self->die( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 'click_button: More than one button selector has been used'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 14 | for ( $args{x}, $args{y} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 28 | ▶ | $_ = 1 unless defined; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 14 | ▶ | my $form = $self->current_form | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | or $self->die('click_button: No form has been selected'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 13 | my $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 13 | ▶ | if ( $args{name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 4 | $request = $form->click( $args{name}, $args{x}, $args{y} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | # 0 is a valid id in HTML5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | elsif ( defined $args{id} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | # HTML::Form expects ids to be prefixed with '#' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 2 | my $input = $form->find_input( '#' . $args{id} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 2 | $request = $input->click( $form, $args{x}, $args{y} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | elsif ( $args{number} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | # changing this 'submit' to qw/submit button image/ will probably break people's code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 2 | my $input = $form->find_input( undef, 'submit', $args{number} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 2 | $request = $input->click( $form, $args{x}, $args{y} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | elsif ( $args{input} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 1 | $request = $args{input}->click( $form, $args{x}, $args{y} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | elsif ( $args{value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | my @inputs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 4 | = map { $form->find_input( undef, $_ ) } qw/submit button image/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 4 | foreach my $input (@inputs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 9 | ▶ | if ( $input->value && ( $args{value} eq $input->value ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$input->value and $args{"value"} eq $input->value
MC/DC50%1/2
$input->value and $args{"value"} eq $input->value
$input->value
$args{"value"} eq $input->value
Truth table66%2/3
A and B
A= $input->valueB= $args{"value"} eq $input->value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 3 | $request = $input->click( $form, $args{x}, $args{y} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | } # foreach | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | } # $args{value} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 10 | return $self->request($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | sub submit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 20 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 20 | my $request = $self->current_form->make_request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 20 | return $self->request($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | sub submit_form { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 37 | ▶ | my ( $self, %args ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_form: called CC=25 SCAR=32.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 37 | for ( keys %args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 61 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | !/^(form_(number|name|fields|id)|(with_)?fields|button|x|y|strict_forms)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 1 | $self->die(qq{Unknown submit_form parameter "$_"}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 36 | my $fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 36 | for (qw/with_fields fields/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 60 | ▶ | if ( $args{$_} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 26 | ▶ | if ( ref $args{$_} eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 24 | $fields = $args{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 2 | $self->die("$_ arg to submit_form must be a hashref"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 24 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 34 | my @filtered_sets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 34 | ▶ | if ( $args{with_fields} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 11 | my @got = $self->all_forms_with_fields( keys %{$fields} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 10 | ▶ | $self->die("There is no form with the requested fields") if not @got; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 8 | push @filtered_sets, \@got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 31 | ▶ | if ( my $form_number = $args{form_number} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 9 | my $got = $self->form_number($form_number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 8 | ▶ | $self->die("There is no form numbered $form_number") if not $got; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 7 | push @filtered_sets, [$got]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 29 | ▶ | if ( my $form_name = $args{form_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 17 | my @got = $self->all_forms_with( name => $form_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 17 | ▶ | $self->die(qq{There is no form named "$form_name"}) if not @got; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 16 | push @filtered_sets, \@got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 28 | ▶ | if ( my $form_id = $args{form_id} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 2 | my @got = $self->all_forms_with( id => $form_id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 2 | ▶ | $self->die(qq{There is no form with ID "$form_id"}) if not @got; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 1 | push @filtered_sets, \@got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 27 | ▶ | if ( not @filtered_sets ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | # No form selector was used. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | # Maybe a form was set separately, or we'll default to the first form. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | # Need to intersect to apply all the various filters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | # Assume that each filtered set only has a given form object once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | # So we can count occurrences. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 26 | ▶ | tie my %c, Tie::RefHash:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | or $self->die('Cannot determine a form to use'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 26 | foreach (@filtered_sets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 32 | foreach (@$_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 42 | ++$c{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 26 | my $expected_count = scalar @filtered_sets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 26 | my @matched = grep { $c{$_} == $expected_count } keys %c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 26 | ▶ | if ( not @matched ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 4 | $self->die('There is no form that satisfies all the criteria'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 22 | ▶ | if ( @matched > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 2 | $self->die('More than one form satisfies all the criteria'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 20 | $self->{current_form} = $matched[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 21 | ▶ | if ( defined( $args{strict_forms} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | # Strict argument has been passed, set the flag as appropriate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | # this must be done prior to attempting to set the fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 6 | $self->current_form->strict( $args{strict_forms} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 21 | ▶ | $self->set_fields( %{$fields} ) if $fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 17 | my $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 17 | ▶ | if ( $args{button} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | $response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | = $self->click( $args{button}, $args{x} || 0, $args{y} || 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$args{'x'} || 0
$args{'y'} || 0
MC/DC0%0/1
$args{'x'} || 0
$args{'x'}
MC/DC0%0/1
$args{'y'} || 0
$args{'y'}
Truth table0%0/2
A
A= $args{'x'}
Truth table0%0/2
A
A= $args{'y'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 17 | $response = $self->submit(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 17 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | sub add_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_header: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 5 | my $npairs = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 5 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 5 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 5 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 5 | ++$npairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 5 | $self->{headers}{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 5 | return $npairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | sub delete_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_header: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | delete $self->{headers}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | sub quiet { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 47 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quiet: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 47 | ▶ | $self->{quiet} = $_[0] if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 47 | return $self->{quiet}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | sub autocheck { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autocheck: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 6 | ▶ | $self->{autocheck} = $_[0] if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 6 | return $self->{autocheck}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | sub stack_depth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 249 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stack_depth: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 249 | ▶ | $self->{stack_depth} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 249 | return $self->{stack_depth}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | sub save_content { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save_content: called CC=10 SCAR=24.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 2 | my $filename = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 2 | my %opts = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 2 | ▶ | if ( delete $opts{binary} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 1 | $opts{binmode} = ':raw'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 1 | $opts{decoded_by_headers} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 2 | ▶ | open( my $fh, '>', $filename ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | or $self->die("Unable to create $filename: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 2 | ▶ | if ( ( my $binmode = delete( $opts{binmode} ) || q{} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
my $binmode = delete $opts{"binmode"} || "" or not $self->content_type =~ m[^text/]
delete $opts{'binmode'} || ''
MC/DC50%1/2
my $binmode = delete $opts{"binmode"} || "" or not $self->content_type =~ m[^text/]
delete $opts{'binmode'}
not $self->content_type =~ m[^text/]
Truth table66%2/3
A or not(B)
A= delete $opts{'binmode'}B= not $self->content_type =~ m[^text/]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | || ( $self->content_type() !~ m{^text/} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 1 | ▶ | if ( length($binmode) && ( substr( $binmode, 0, 1 ) eq ':' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $binmode and substr($binmode, 0, 1) eq ":"
MC/DC0%0/2
length $binmode and substr($binmode, 0, 1) eq ":"
length $binmode
substr($binmode, 0, 1) eq ":"
Truth table33%1/3
A and B
A= length $binmodeB= substr($binmode, 0, 1) eq ":"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 1 | binmode $fh, $binmode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | binmode $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 2 | ▶ | print {$fh} $self->content(%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | or $self->die("Unable to write to $filename: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 2 | ▶ | close $fh or $self->die("Unable to close $filename: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | sub _get_fh_default_stdout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_fh_default_stdout: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 3 | ▶ | my $p = shift || q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 3 | ▶ | if ( !$p ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 1 | return \*STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | elsif ( !ref($p) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 1 | ▶ | open my $fh, '>', $p or $self->die("Unable to write to $p: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 1 | return $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 1 | return $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | sub dump_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_headers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 3 | my $fh = $self->_get_fh_default_stdout(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 3 | print {$fh} $self->response->headers_as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | sub dump_links { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_links: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 5 | ▶ | my $fh = shift || \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || \*STDOUT
MC/DC100%1/1
shift() || \*STDOUT
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 5 | my $absolute = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 5 | for my $link ( $self->links ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 64 | ▶ | my $url = $absolute ? $link->url_abs : $link->url; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 64 | ▶ | $url = q{} if not defined $url; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 64 | print {$fh} $url, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | sub dump_images { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_images: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 5 | ▶ | my $fh = shift || \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || \*STDOUT
MC/DC100%1/1
shift() || \*STDOUT
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 5 | my $absolute = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 5 | for my $image ( $self->images ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 26 | ▶ | my $url = $absolute ? $image->url_abs : $image->url; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 26 | ▶ | $url = q{} if not defined $url; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 26 | print {$fh} $url, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | sub dump_forms { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_forms: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 7 | ▶ | my $fh = shift || \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || \*STDOUT
MC/DC100%1/1
shift() || \*STDOUT
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 7 | for my $form ( $self->forms ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 23 | print {$fh} $form->dump, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | sub dump_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_text: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 2 | ▶ | my $fh = shift || \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || \*STDOUT
MC/DC100%1/1
shift() || \*STDOUT
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 2 | print {$fh} $self->text, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 2 | my $clone = $self->SUPER::clone(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 2 | $clone->cookie_jar( $self->cookie_jar ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 2 | $clone->{headers} = { %{ $self->{headers} } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 2 | return $clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | sub redirect_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
redirect_ok: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 1 | my $prospective_request = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 1 | my $response = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 1 | my $ok = $self->SUPER::redirect_ok( $prospective_request, $response ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 1 | ▶ | if ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 1 | $self->{redirected_uri} = $prospective_request->uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 1 | return $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | sub request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 180 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 180 | my $request = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 180 | ▶ | $self->die('->request was called without a request parameter') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | unless $request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 178 | $request = $self->_modify_request($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 178 | ▶ | if ( $request->method eq 'GET' || $request->method eq 'POST' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$request->method eq "GET" or $request->method eq "POST"
MC/DC100%2/2
$request->method eq "GET" or $request->method eq "POST"
$request->method eq "GET"
$request->method eq "POST"
Truth table100%3/3
A or B
A= $request->method eq "GET"B= $request->method eq "POST"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 176 | $self->_push_page_stack(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 178 | return $self->_update_page( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | $request, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | $self->_make_request( $request, @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | sub update_html { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 183 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_html: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 183 | my $html = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 183 | $self->_reset_page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 183 | $self->{ct} = 'text/html'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 183 | $self->{content} = $html; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 183 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | sub credentials { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
credentials: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | # The latest LWP::UserAgent also supports 2 arguments, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | # in which case the first is host:port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 8 | ▶ | if ( @_ == 4 || ( @_ == 2 && $_[0] =~ /:\d+$/ ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@_ == 4 or @_ == 2 and $_[0] =~ /:\d+$/
@_ == 2 and $_[0] =~ /:\d+$/
MC/DC33%1/3
@_ == 4 or @_ == 2 and $_[0] =~ /:\d+$/
@_ == 4
@_ == 2
$_[0] =~ /:\d+$/
Truth table50%2/4
A or B and C
A= @_ == 4B= @_ == 2C= $_[0] =~ /:\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 4 | return $self->SUPER::credentials(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 4 | ▶ | @_ == 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | or $self->die('Invalid # of args for overridden credentials()'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 3 | return @$self{qw( __username __password )} = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | sub get_basic_credentials { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_basic_credentials: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 9 | my @cred = grep { defined } @$self{qw( __username __password )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 9 | ▶ | return @cred if @cred == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 4 | return $self->SUPER::get_basic_credentials(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | sub clear_credentials { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_credentials: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 1 | delete @$self{qw( __username __password )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | sub _update_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 207 | ▶ | my ( $self, $request, $res ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_page: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 207 | $self->{req} = $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 207 | $self->{redirected_uri} = $request->uri->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 207 | $self->{res} = $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 207 | $self->{status} = $res->code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 207 | $self->{base} = $res->base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 207 | ▶ | $self->{ct} = $res->content_type || q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$res->content_type || ''
MC/DC100%1/1
$res->content_type || ''
$res->content_type
Truth table100%2/2
A
A= $res->content_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | 207 | ▶ | if ( $res->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | 189 | $self->{uri} = $self->{redirected_uri}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 189 | $self->{last_uri} = $self->{uri}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 207 | ▶ | if ( $res->is_error ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 18 | ▶ | if ( $self->{autocheck} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 2 | $self->die( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 'Error ', $request->method, 'ing ', $request->uri, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | ': ', $res->message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 205 | $self->_reset_page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | # Try to decode the content. Undef will be returned if there's nothing to decompress. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | # See docs in HTTP::Message for details. Do we need to expose the options there? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 205 | my $content = $res->decoded_content(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 205 | ▶ | $content = $res->content if ( not defined $content ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 205 | ▶ | if ( $self->is_html ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | 179 | $self->update_html($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 26 | $self->{content} = $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | 205 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | } # _update_page | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | sub _modify_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 180 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_modify_request: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 180 | my $req = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | # add correct Accept-Encoding header to restore compliance with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | # http://www.freesoft.org/CIE/RFC/2068/158.htm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | # http://use.perl.org/~rhesa/journal/25952 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 180 | ▶ | if ( not $req->header('Accept-Encoding') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | # "identity" means "please! unencoded content only!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 178 | ▶ | $req->header( 'Accept-Encoding', $HAS_ZLIB ? 'gzip' : 'identity' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 180 | my $last = $self->{last_uri}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | 180 | ▶ | if ($last) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 121 | ▶ | $last = $last->as_string if ref($last); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 121 | $req->header( Referer => $last ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 180 | ▶ | while ( my ( $key, $value ) = each %{ $self->{headers} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 5 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 4 | $req->header( $key => $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 1 | $req->remove_header($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 180 | return $req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | sub _make_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 181 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_request: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 181 | return $self->SUPER::request(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | sub _reset_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 464 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reset_page: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 464 | $self->{links} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 464 | $self->{images} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | 464 | $self->{forms} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | 464 | $self->{current_form} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 464 | $self->{title} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 464 | $self->{text} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 464 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 58 | my %link_tags = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | a => 'href', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | area => 'href', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | frame => 'src', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | iframe => 'src', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | link => 'href', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | meta => 'content', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | sub _new_parser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 37 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_parser: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | 37 | my $content_ref = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 37 | my $parser = HTML::TokeParser->new($content_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 37 | $parser->marked_sections( $self->{marked_sections} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 37 | $parser->xml_mode( $$content_ref =~ /^\s*<\?xml/ ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | ; # NOT GENERALLY RELIABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 37 | return $parser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | sub _extract_links { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 33 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_links: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 33 | $self->{links} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 33 | ▶ | if ( defined $self->{content} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 31 | my $parser = $self->_new_parser( \$self->{content} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 31 | ▶ | while ( my $token = $parser->get_tag( keys %link_tags ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 232 | my $link = $self->_link_from_token( $token, $parser ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 232 | ▶ | push( @{ $self->{links} }, $link ) if $link; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | } # while | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 33 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 58 | my %image_tags = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | img => 'src', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | input => 'src', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | sub _extract_images { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_images: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 7 | $self->{images} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 7 | ▶ | if ( defined $self->{content} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 7 | ▶ | if ( $self->content_type eq 'text/css' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | push( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 1 | @{ $self->{images} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | $self->_images_from_css( $self->{content} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | 6 | my $parser = $self->_new_parser( \$self->{content} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 6 | ▶ | while ( my $token = $parser->get_tag() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | 259 | my ( $tag_name, $attrs ) = @{$token}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | 259 | ▶ | next if $tag_name =~ m{^/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 160 | ▶ | if ( $image_tags{$tag_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 50 | my $image = $self->_image_from_token($token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 50 | ▶ | push( @{ $self->{images} }, $image ) if $image; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | elsif ( $tag_name eq 'style' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | push( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 4 | @{ $self->{images} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | $self->_images_from_css( $parser->get_text ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 160 | ▶ | if ( $attrs->{style} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | push( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | 10 | @{ $self->{images} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | $self->_images_from_css( $attrs->{style} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | 10 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | } # while | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | sub _image_from_token { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | 50 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_image_from_token: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 50 | my $token = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 50 | my $tag = $token->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | 50 | my $attrs = $token->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | 50 | ▶ | if ( $tag eq 'input' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | 24 | ▶ | my $type = $attrs->{type} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 23 | ▶ | return unless $type eq 'image'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 29 | require WWW::Mechanize::Image; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | return WWW::Mechanize::Image->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | tag => $tag, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | base => $self->base, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | url => $attrs->{src}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | name => $attrs->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | height => $attrs->{height}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | width => $attrs->{width}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | alt => $attrs->{alt}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 29 | attrs => $attrs, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 58 | my $STYLE_URL_REGEXP = qr{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | # ex. "url('/site.css')" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | ( # capture non url path of the string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | url # url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | \s* # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | \( # ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | \s* # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | (['"]?) # opening ' or " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | ( # the rest is url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | .+? # non greedy "everything" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | \2 # closing ' or " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | \s* # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | \) # ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | }xmsi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | sub _images_from_css { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_images_from_css: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 15 | my $css = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | 15 | my @images; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | 15 | ▶ | while ( $css =~ m/$STYLE_URL_REGEXP/g ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | 11 | my $url = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 11 | require WWW::Mechanize::Image; ## no perlimports | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 11 | push( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | @images, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | WWW::Mechanize::Image->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | tag => 'css', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | base => $self->base, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | name => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | height => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | width => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | alt => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 15 | return @images; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | sub _link_from_token { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | 232 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_link_from_token: called CC=14 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | 232 | my $token = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 232 | my $parser = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | 232 | my $tag = $token->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 232 | my $attrs = $token->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | 232 | my $url = $attrs->{ $link_tags{$tag} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 232 | my $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | my $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | 232 | ▶ | if ( $tag eq 'a' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | # Stop collecting text at the next <a> start tag as well as at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | # the closing </a>, so that an unclosed <a> does not swallow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | # subsequent links (GH#212). get_trimmed_text() (via get_text()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | # ungets the stop tag, so the outer get_tag() loop will still | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | # see the next <a>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | 178 | $text = $parser->get_trimmed_text( $tag, "/$tag" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | 178 | ▶ | $text = q{} unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | 178 | my $onClick = $attrs->{onclick}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | 178 | ▶ | if ( $onClick && ( $onClick =~ /^window\.open\(\s*'([^']+)'/ ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$onClick and $onClick =~ /^window\.open\(\s*'([^']+)'/
MC/DC100%2/2
$onClick and $onClick =~ /^window\.open\(\s*'([^']+)'/
$onClick
$onClick =~ /^window\.open\(\s*'([^']+)'/
Truth table100%3/3
A and B
A= $onClickB= $onClick =~ /^window\.open\(\s*'([^']+)'/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | 3 | $url = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | ▶ | elsif ($url | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$url and $url =~ /^javascript\:\s*(?:void\(\s*)?window\.open\(\s*'([^']+)'/s
MC/DC100%2/2
$url and $url =~ /^javascript\:\s*(?:void\(\s*)?window\.open\(\s*'([^']+)'/s
$url
$url =~ /^javascript\:\s*(?:void\(\s*)?window\.open\(\s*'([^']+)'/s
Truth table100%3/3
A and B
A= $urlB= $url =~ /^javascript\:\s*(?:void\(\s*)?window\.open\(\s*'([^']+)'/s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | && $url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | =~ /^javascript\:\s*(?:void\(\s*)?window\.open\(\s*'([^']+)'/s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | 3 | $url = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | } # a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | # Of the tags we extract from, only 'AREA' has an alt tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | # The rest should have a 'name' attribute. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | # ... but we don't do anything with that bit of wisdom now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | 232 | $name = $attrs->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | 232 | ▶ | if ( $tag eq 'meta' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 18 | my $equiv = $attrs->{'http-equiv'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 18 | my $content = $attrs->{'content'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | 18 | ▶ | unless $equiv && ( lc $equiv eq 'refresh' ) && defined $content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$equiv and lc $equiv eq "refresh" and defined $content
$equiv and lc $equiv eq "refresh"
MC/DC66%2/3
$equiv and lc $equiv eq "refresh" and defined $content
$equiv
lc $equiv eq "refresh"
defined $content
Truth table75%3/4
A and B and C
A= $equivB= lc $equiv eq "refresh"C= defined $content
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 7 | ▶ | if ( $content =~ /^\d+\s*;\s*url\s*=\s*(\S+)/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 7 | $url = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | 7 | ▶ | $url =~ s/^"(.+)"$/$1/ or $url =~ s/^'(.+)'$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | 0 | undef $url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | } # meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 221 | ▶ | unless defined $url; # probably just a name link or <AREA NOHREF...> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 217 | require WWW::Mechanize::Link; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 217 | return WWW::Mechanize::Link->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | text => $text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | tag => $tag, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | base => $self->base, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | attrs => $attrs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | } # _link_from_token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | sub _extract_forms { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | 79 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_forms: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | my @forms = HTML::Form->parse( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | $self->content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | base => $self->base, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | strict => $self->{strict_forms}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | verbose => $self->{verbose_forms}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | 79 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | 77 | $self->{forms} = \@forms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 77 | for my $form (@forms) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 353 | for my $input ( $form->inputs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 1183 | ▶ | if ( $input->type eq 'file' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | 29 | $input->value(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | 77 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | sub _push_page_stack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | 179 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_push_page_stack: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 179 | my $req = $self->{req}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | 179 | my $res = $self->{res}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 179 | ▶ | return unless $req && $res && $self->stack_depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$req and $res and $self->stack_depth
$req and $res
MC/DC66%2/3
$req and $res and $self->stack_depth
$req
$res
$self->stack_depth
Truth table75%3/4
A and B and C
A= $reqB= $resC= $self->stack_depth
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | # Don't push anything if it's a virgin object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | 121 | ▶ | my $stack = $self->{page_stack} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"page_stack"} ||= []
MC/DC100%1/1
$self->{"page_stack"} ||= []
$self->{"page_stack"}
Truth table100%2/2
A
A= $self->{"page_stack"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | 121 | ▶ | if ( @{$stack} >= $self->stack_depth ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | 2 | shift @{$stack}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | 121 | push( @{$stack}, { req => $req, res => $res } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 121 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | sub warn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | 38 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warn: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 38 | ▶ | return unless my $handler = $self->{onwarn}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | 38 | ▶ | return if $self->quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | 32 | return $handler->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | sub die { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | 30 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
die: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | 30 | ▶ | return unless my $handler = $self->{onerror}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | 29 | return $handler->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | # NOT an object method! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | sub _warn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | 30 | ▶ | require Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_warn: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | 30 | return &Carp::carp; ## no critic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | # NOT an object method! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | sub _die { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | 29 | ▶ | require Carp; ## no perlimports | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_die: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | 29 | return &Carp::croak; ## no critic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | 58 | 1; # End of module | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||