Cookie/Domain.pm

filter: Statementstmt 36.3% 125 / 344 Branchbran 11.6% 23 / 198 Conditioncond 10.6% 10 / 94 MC/DCmcdc 1.8% 1 / 53 Subroutinesub 70.7% 29 / 41 Podpod 100% 15 / 15 totaltotal 27.2% 203 / 745 CC 135 SCAR 64.3
CC
135
Cov
25%
cron_fetch
1892.0
stat
653.3
load
307.6
CRAP 617.7
« Cookie/Jar.pm ↑ Summary Cookie.pm »
1 ##----------------------------------------------------------------------------
2 ## Cookies API for Server & Client - ~/lib/Cookie/Domain.pm
3 ## Version v0.1.9
4 ## Copyright(c) 2025 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/05/06
7 ## Modified 2026/10/09
8 ## You can use, copy, modify and redistribute this package and associated
9 ## files under the same terms as Perl itself.
10 ##----------------------------------------------------------------------------
11 package Cookie::Domain;
12 BEGIN
13 9 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
14 9 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 9 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 9 ▶ use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 9 ▶ use parent qw( Module::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
18 9 ▶ use vars qw( $DOMAIN_RE $PUBLIC_SUFFIX_DATA $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 9 ▶ use DateTime::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 9 ▶ use DateTime::Format::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 9 ▶ use Module::Generic::File qw( tempfile );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 9 ▶ use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 9 ▶ use Net::IDN::Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 9 ▶ use Wanted;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 9 ▶ use constant URL => 'https://publicsuffix.org/list/effective_tld_names.dat';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 # Properly formed domain name according to rfc1123
27 9 our $DOMAIN_RE = qr/^
28 (?:
29 [[:alnum:]]
30 (?:
31 (?:[[:alnum:]-]){0,61}
32 [[:alnum:]]
33 )?
34 (?:
35 \.[[:alnum:]]
36 (?:
37 (?:[[:alnum:]-]){0,61}
38 [[:alnum:]]
39 )?
40 )*
41 )
42 $/x;
43 9 our $VERSION = 'v0.1.9';
44 };
45  
46 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 sub init
50 2 ▶{
Subroutine init: called CC=4 SCAR=14.7
Pod documented
51 2 my $self = shift( @_ );
52 2 my $base = Module::Generic::File::file( __FILE__ )->parent;
53 2 $self->{file} = $base->child( 'public_suffix_list.txt' );
54 2 $self->{json_file} = Module::Generic::File->sys_tmpdir->child( 'public_suffix.json' );
55 2 $self->{meta} = {};
56 2 $self->{min_suffix} = 0;
57 2 $self->{suffixes} = {};
58 2 $self->{_init_strict_use_sub} = 1;
59 2 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 2 0 2
60 2 ▶ unless( $self->{no_load} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"no_load"}) 2 0 2
61 {
62 2 ▶ $self->load || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->load or return $self->pass_error 0 0 0
63 }
64 0 return( $self );
65 }
66  
67 sub cron_fetch
68 0 ▶{
Subroutine cron_fetch: not called CC=43 SCAR=75.5
Pod documented
69 # Cookie::Domain->cron_fetch
70 # $obj->cron_fetch
71 # Cookie::Domain->cron_fetch( $hash_ref );
72 # $obj->cron_fetch( $hash_ref );
73 # Cookie::Domain->cron_fetch( %options );
74 # $obj->cron_fetch( %options );
75 0 my( $this, $self );
76 0 my $opts = {};
77 0 ▶ if( scalar( @_ ) && ( ref( $_[0] ) eq __PACKAGE__ || $_[0] eq __PACKAGE__ ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ and ref $_[0] eq __PACKAGE__ || $_[0] eq __PACKAGE__) 0 0 0
Condition0%0/6
scalar @_ and ref $_[0] eq __PACKAGE__ || $_[0] eq __PACKAGE__
!ll&&!rl&&r
000
ref $_[0] eq __PACKAGE__ or $_[0] eq __PACKAGE__
l!l&&r!l&&!r
000
MC/DC0%0/3
scalar @_ and ref $_[0] eq __PACKAGE__ || $_[0] eq __PACKAGE__
scalar @_ ref $_[0] eq __PACKAGE__ $_[0] eq __PACKAGE__
Truth table0%0/4
A and B or C
A= scalar @_B= ref $_[0] eq __PACKAGE__C= $_[0] eq __PACKAGE__
ABCresult
0XX0
1000
11X1
1011
78 {
79 0 $this = shift( @_ );
80 }
81 0 ▶ if( @_ == 1 && ref( $_[0] ) eq 'HASH' )
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'HASH') { } 0 0 0
elsif (not scalar(@_) % 2) { } 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
82 {
83 0 $opts = shift( @_ );
84 }
85 elsif( !( scalar( @_ ) % 2 ) )
86 {
87 0 $opts = { @_ };
88 }
89  
90 0 ▶ if( ref( $this ) )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $this) { } 0 0 0
91 {
92 0 $self = $this;
93 }
94 else
95 {
96 0 ▶ $this //= __PACKAGE__;
Condition0%0/2
$this //= __PACKAGE__
l!l
00
MC/DC0%0/1
$this //= __PACKAGE__
$this
Truth table0%0/2
A
A= $this
Aresult
11
00
97 0 $self = $this->new( $opts );
98 }
99 0 ▶ $opts->{file} //= '';
Condition0%0/2
$opts->{"file"} //= ""
l!l
00
MC/DC0%0/1
$opts->{"file"} //= ""
$opts->{"file"}
Truth table0%0/2
A
A= $opts->{"file"}
Aresult
11
00
100 0 ▶ my $file = $opts->{file} || $self->file;
Condition0%0/3
$opts->{'file'} || $self->file
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{'file'} || $self->file
$opts->{'file'} $self->file
Truth table0%0/3
A || B
A= $opts->{'file'}B= $self->file
ABresult
1X1
011
000
101 0 ▶ $file = $self->_is_a( $file, 'Module::Generic::File' ) ? $file : Module::Generic::File::file( $file );
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_a($file, 'Module::Generic::File') ? : 0 0 0
102 0 require LWP::UserAgent;
103 0 my $ua = LWP::UserAgent->new(
104 agent => "Cookie::Domain/" . $VERSION,
105 );
106 0 my $meta = $self->meta;
107 0 my $req_headers = {};
108 0 my $dont_have_etag = 0;
109 my $mtime = $meta->{db_last_modified}
110 ? $meta->{db_last_modified}
111 0 ▶ : ( $file->exists && !$file->is_empty )
Branch: 2 branches
BranchTrueFalseTotal
$meta->{'db_last_modified'} ? : 0 0 0
$file->exists && !$file->is_empty ? : 0 0 0
Condition0%0/3
$file->exists and not $file->is_empty
!ll&&!rl&&r
000
MC/DC0%0/2
$file->exists and not $file->is_empty
$file->exists not $file->is_empty
Truth table0%0/3
A and not(B)
A= $file->existsB= not $file->is_empty
ABresult
0X0
100
111
112 ? $file->mtime
113 : undef;
114 # If we have already a local file and it is not empty, let's use the etag when making the request
115 0 ▶ if( $meta->{etag} && $file->exists && !$file->is_empty )
Branch: 2 branches
BranchTrueFalseTotal
if ($meta->{'etag'} and $file->exists and not $file->is_empty) { } 0 0 0
elsif (not $meta->{'etag'}) { } 0 0 0
Condition0%0/6
$meta->{"etag"} and $file->exists and not $file->is_empty
!ll&&!rl&&r
000
$meta->{"etag"} and $file->exists
!ll&&!rl&&r
000
MC/DC0%0/3
$meta->{"etag"} and $file->exists and not $file->is_empty
$meta->{"etag"} $file->exists not $file->is_empty
Truth table0%0/4
A and B and not(C)
A= $meta->{"etag"}B= $file->existsC= not $file->is_empty
ABCresult
0XX0
10X0
1100
1111
116 {
117 0 $meta->{etag} =~ s/^\"([^"]+)\"$/$1/;
118 0 $req_headers->{'If-None-Match'} = qq{"$meta->{etag}"};
119 }
120 elsif( !$meta->{etag} )
121 {
122 0 $dont_have_etag = 1;
123 # <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since>
124 0 ▶ if( defined( $mtime ) && $mtime )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mtime and $mtime) 0 0 0
Condition0%0/3
defined $mtime and $mtime
!ll&&!rl&&r
000
MC/DC0%0/2
defined $mtime and $mtime
defined $mtime $mtime
Truth table0%0/3
A and B
A= defined $mtimeB= $mtime
ABresult
0X0
100
111
125 {
126 0 my $dt = $self->_parse_timestamp( $mtime );
127 0 ▶ if( $dt )
Branch: 1 branch
BranchTrueFalseTotal
if ($dt) 0 0 0
128 {
129 # HTTP Date format
130 0 my $dt_fmt = DateTime::Format::Lite->new(
131 pattern => '%a, %d %b %Y %H:%M:%S GMT',
132 locale => 'en_GB',
133 time_zone => 'GMT',
134 );
135 0 $dt->set_formatter( $dt_fmt );
136 0 $req_headers->{ 'If-Modified-Since' } = $dt;
137 }
138 }
139 }
140  
141 # try-catch
142 0 local $@;
143 my $resp = eval
144 0 {
145 0 $ua->get( URL, %$req_headers );
146 };
147 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
148 {
149 0 return( $self->error( "Error trying to perform an HTTP GET request to ", URL, ": $@" ) );
150 }
151 0 my $code = $resp->code;
152 # try-catch
153 my $data = eval
154 0 {
155 0 $resp->decoded_content( default_charset => 'utf-8', alt_charset => 'utf-8' );
156 };
157 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
158 {
159 0 return( $self->error( "Error decoding response content: $@" ) );
160 }
161 0 my $last_mod = $resp->header( 'Last-Modified' );
162  
163 0 my $tz;
164 # DateTime::Lite::TimeZone::Local will die ungracefully if the local timezeon is not set with the error:
165 # "Cannot determine local time zone"
166 # try-catch
167 $tz = eval
168 0 {
169 0 DateTime::Lite::TimeZone->new( name => 'local' );
170 };
171 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
172 {
173 0 $tz = DateTime::Lite::TimeZone->new( name => 'UTC' );
174 }
175  
176 0 ▶ if( $last_mod )
Branch: 1 branch
BranchTrueFalseTotal
if ($last_mod) { } 0 0 0
177 {
178 0 $last_mod = $self->_parse_timestamp( $last_mod )->set_time_zone( $tz );
179 }
180 else
181 {
182 0 $last_mod = DateTime::Lite->now( time_zone => $tz );
183 }
184 0 my $epoch = $last_mod->epoch;
185 0 ▶ if( $resp->header( 'etag' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($resp->header("etag")) 0 0 0
186 {
187 0 ▶ $dont_have_etag = $resp->header( 'etag' ) eq ( $meta->{etag} // '' ) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$resp->header('etag') eq ($meta->{'etag'} // '') ? : 0 0 0
Condition0%0/2
$meta->{"etag"} // ""
l!l
00
MC/DC0%0/1
$meta->{"etag"} // ""
$meta->{"etag"}
Truth table0%0/2
A
A= $meta->{"etag"}
Aresult
11
00
188 0 $meta->{etag} = $resp->header( 'etag' );
189 0 $meta->{etag} =~ s/^\"([^"]+)\"$/$1/;
190 }
191  
192 0 ▶ if( $code == 304 ||
Branch: 3 branches
BranchTrueFalseTotal
if ($code == 304 or not $file->is_empty and $mtime and $mtime == $epoch) { } 0 0 0
elsif ($code ne 200) { } 0 0 0
elsif (not length $data) { } 0 0 0
Condition0%0/9
$code == 304 or not $file->is_empty and $mtime and $mtime == $epoch
l!l&&r!l&&!r
000
not $file->is_empty and $mtime and $mtime == $epoch
!ll&&!rl&&r
000
not $file->is_empty and $mtime
!ll&&!rl&&r
000
MC/DC0%0/4
$code == 304 or not $file->is_empty and $mtime and $mtime == $epoch
$code == 304 not $file->is_empty $mtime $mtime == $epoch
Truth table0%0/5
A or not(B) and C and D
A= $code == 304B= not $file->is_emptyC= $mtimeD= $mtime == $epoch
ABCDresult
1XXX1
01111
00XX0
010X0
01100
193 ( !$file->is_empty && $mtime && $mtime == $epoch ) )
194 {
195 0 ▶ if( !$self->suffixes->length )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->suffixes->length) 0 0 0
196 {
197 0 ▶ $self->load_public_suffix || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->load_public_suffix or return $self->pass_error 0 0 0
198 }
199 # Did not have an etag, but I do have one now
200 0 ▶ if( $dont_have_etag && $meta->{etag} )
Branch: 1 branch
BranchTrueFalseTotal
if ($dont_have_etag and $meta->{"etag"}) 0 0 0
Condition0%0/3
$dont_have_etag and $meta->{"etag"}
!ll&&!rl&&r
000
MC/DC0%0/2
$dont_have_etag and $meta->{"etag"}
$dont_have_etag $meta->{"etag"}
Truth table0%0/3
A and B
A= $dont_have_etagB= $meta->{"etag"}
ABresult
0X0
100
111
201 {
202 0 ▶ $self->save_as_json || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->save_as_json or return $self->pass_error 0 0 0
203 }
204 0 return( $self );
205 }
206 elsif( $code ne 200 )
207 {
208 0 return( $self->error( "Failed to get the remote public domain list. Server responded with code '$code': ", $resp->as_string ) );
209 }
210 elsif( !length( $data ) )
211 {
212 0 return( $self->error( "Remote server returned no data." ) );
213 }
214 0 ▶ $file->unload_utf8( $data, { lock => 1 } ) || return( $self->error( "Unable to open public suffix data file \"$file\" in write mode: ", $file->error ) );
Branch: 1 branch
BranchTrueFalseTotal
$file->unload_utf8($data, {"lock", 1}) or return $self->error(qq[Unable to open public suffix data file "$file" in write mode: ], $file->error) 0 0 0
215 0 $file->unlock;
216 0 $file->utime( $epoch, $epoch );
217 0 ▶ $self->load_public_suffix || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->load_public_suffix or return $self->pass_error 0 0 0
218 0 ▶ $self->save_as_json || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->save_as_json or return $self->pass_error 0 0 0
219  
220 0 return( $self );
221 }
222  
223 sub decode
224 0 ▶{
Subroutine decode: not called CC=3 SCAR=24.8
Pod documented
225 0 my $self = shift( @_ );
226 0 my $name = shift( @_ );
227 0 ▶ return( '' ) if( !length( $name ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length $name 0 0 0
228 # try-catch
229 0 local $@;
230 my $rv = eval
231 0 {
232 0 return( Net::IDN::Encode::domain_to_ascii( $name ) );
233 };
234 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
235 {
236 0 return( $self->error( "An unexpected error occurred while decoding a domain name: $@" ) );
237 }
238 0 return( $rv );
239 }
240  
241 sub encode
242 0 ▶{
Subroutine encode: not called CC=3 SCAR=24.8
Pod documented
243 0 my $self = shift( @_ );
244 0 my $name = shift( @_ );
245 0 ▶ return( '' ) if( !length( $name ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length $name 0 0 0
246 # try-catch
247 0 local $@;
248 my $rv = eval
249 0 {
250 0 return( Net::IDN::Encode::domain_to_unicode( $name ) );
251 };
252 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
253 {
254 0 return( $self->error( "An unexpected error occurred while encoding a domain name: $@" ) );
255 }
256 0 return( $rv );
257 }
258  
259 2 ▶sub file { return( shift->_set_get_object_without_init( 'file', 'Module::Generic::File', @_ ) ); }
Subroutine file: called CC=1 SCAR=0.0
Pod documented
260  
261 2 ▶sub json_file { return( shift->_set_get_object_without_init( 'json_file', 'Module::Generic::File', @_ ) ); }
Subroutine json_file: called CC=1 SCAR=0.0
Pod documented
262  
263 sub load
264 2 ▶{
Subroutine load: called CC=23 SCAR=57.3
Pod documented
265 2 my $self = shift( @_ );
266 2 my $f = $self->file;
267 2 my $json_file = $self->json_file;
268 2 ▶ if( defined( $PUBLIC_SUFFIX_DATA ) && ref( $PUBLIC_SUFFIX_DATA ) eq 'HASH' )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $Cookie::Domain::PUBLIC_SUFFIX_DATA and ref $Cookie::Domain::PUBLIC_SUFFIX_DATA eq 'HASH') { } 0 2 2
elsif ($json_file and $json_file->exists) { } 0 2 2
Condition33%1/3
defined $Cookie::Domain::PUBLIC_SUFFIX_DATA and ref $Cookie::Domain::PUBLIC_SUFFIX_DATA eq "HASH"
!ll&&!rl&&r
200
MC/DC0%0/2
defined $Cookie::Domain::PUBLIC_SUFFIX_DATA and ref $Cookie::Domain::PUBLIC_SUFFIX_DATA eq "HASH"
defined $Cookie::Domain::PUBLIC_SUFFIX_DATA ref $Cookie::Domain::PUBLIC_SUFFIX_DATA eq "HASH"
Truth table33%1/3
A and B
A= defined $Cookie::Domain::PUBLIC_SUFFIX_DATAB= ref $Cookie::Domain::PUBLIC_SUFFIX_DATA eq "HASH"
ABresult
0X0
100
111
269 {
270 0 $self->suffixes( $PUBLIC_SUFFIX_DATA );
271 0 $self->meta( {} );
272 }
273 ▶ elsif( $json_file && $json_file->exists )
Condition33%1/3
$json_file and $json_file->exists
!ll&&!rl&&r
020
MC/DC0%0/2
$json_file and $json_file->exists
$json_file $json_file->exists
Truth table33%1/3
A and B
A= $json_fileB= $json_file->exists
ABresult
0X0
100
111
274 {
275 0 ▶ if( !$self->load_json( $json_file ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->load_json($json_file)) 0 0 0
276 {
277 # If there was an error loading the JSON, we rebuild it.
278 # We check the error string as produced in our method 'load_json' below
279 # We try up to 3 times before we give up.
280 0 ▶ if( $self->error->message =~ /error occurred while trying to load json data/i && ++$self->{load_json_attempt} < 4 )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error->message =~ /error occurred while trying to load json data/i and ++$self->{'load_json_attempt'} < 4) { } 0 0 0
Condition0%0/3
$self->error->message =~ /error occurred while trying to load json data/i and ++$self->{"load_json_attempt"} < 4
!ll&&!rl&&r
000
MC/DC0%0/2
$self->error->message =~ /error occurred while trying to load json data/i and ++$self->{"load_json_attempt"} < 4
$self->error->message =~ /error occurred while trying to load json data/i ++$self->{"load_json_attempt"} < 4
Truth table0%0/3
A and B
A= $self->error->message =~ /error occurred while trying to load json data/iB= ++$self->{"load_json_attempt"} < 4
ABresult
0X0
100
111
281 {
282 0 ▶ $self->load_public_suffix( $f ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->load_public_suffix($f) or return $self->pass_error 0 0 0
283 0 ▶ $self->save_as_json( $json_file ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->save_as_json($json_file) or return $self->pass_error 0 0 0
284 0 return( $self );
285 }
286 else
287 {
288 0 return( $self->pass_error );
289 }
290 }
291 0 my $meta = $self->meta;
292 0 ▶ if( $f && $f->exists )
Branch: 1 branch
BranchTrueFalseTotal
if ($f and $f->exists) 0 0 0
Condition0%0/3
$f and $f->exists
!ll&&!rl&&r
000
MC/DC0%0/2
$f and $f->exists
$f $f->exists
Truth table0%0/3
A and B
A= $fB= $f->exists
ABresult
0X0
100
111
293 {
294 0 ▶ if( defined( $meta->{db_last_modified} ) && $meta->{db_last_modified} =~ /^\d{10}$/ )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $meta->{'db_last_modified'} and $meta->{'db_last_modified'} =~ /^\d{10}$/) { } 0 0 0
Condition0%0/3
defined $meta->{"db_last_modified"} and $meta->{"db_last_modified"} =~ /^\d{10}$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $meta->{"db_last_modified"} and $meta->{"db_last_modified"} =~ /^\d{10}$/
defined $meta->{"db_last_modified"} $meta->{"db_last_modified"} =~ /^\d{10}$/
Truth table0%0/3
A and B
A= defined $meta->{"db_last_modified"}B= $meta->{"db_last_modified"} =~ /^\d{10}$/
ABresult
0X0
100
111
295 {
296 0 my $mtime = $f->mtime;
297 0 ▶ if( $mtime > $meta->{db_last_modified} )
Branch: 1 branch
BranchTrueFalseTotal
if ($mtime > $meta->{"db_last_modified"}) 0 0 0
298 {
299 0 ▶ $self->load_public_suffix( $f ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->load_public_suffix($f) or return $self->pass_error 0 0 0
300 0 ▶ $self->save_as_json( $json_file ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->save_as_json($json_file) or return $self->pass_error 0 0 0
301 }
302 }
303 else
304 {
305 0 ▶ $self->load_public_suffix( $f ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->load_public_suffix($f) or return $self->pass_error 0 0 0
306 0 ▶ $self->save_as_json( $json_file ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->save_as_json($json_file) or return $self->pass_error 0 0 0
307 }
308 }
309 }
310 else
311 {
312 2 ▶ return( $self->error( "No public suffix data file or json cache data file was specified." ) ) if( !$json_file && !$f );
Branch: 1 branch
BranchTrueFalseTotal
unless $json_file or $f 0 2 2
Condition33%1/3
$json_file or $f
l!l&&r!l&&!r
200
MC/DC0%0/2
$json_file or $f
$json_file $f
Truth table33%1/3
A or B
A= $json_fileB= $f
ABresult
1X1
011
000
313 2 ▶ $self->load_public_suffix( $f ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->load_public_suffix($f) or return $self->pass_error 2 0 2
314 2 ▶ $self->save_as_json( $json_file ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->save_as_json($json_file) or return $self->pass_error 0 0 0
315 }
316 0 return( $self );
317 }
318  
319 sub load_json
320 0 ▶{
Subroutine load_json: not called CC=12 SCAR=50.5
Pod documented
321 0 my $self = shift( @_ );
322 0 ▶ my $file = shift( @_ ) || $self->json_file || return( $self->error( "No json file was specified." ) );
Condition0%0/5
shift @_ || $self->json_file || (return $self->error('No json file was specified.'))
l!l
00
shift @_ or $self->json_file
l!l&&r!l&&!r
000
MC/DC0%0/2
shift @_ || $self->json_file || (return $self->error('No json file was specified.'))
shift @_ $self->json_file
Truth table0%0/3
A or B
A= shift @_B= $self->json_file
ABresult
1X1
011
000
323 0 ▶ $file = $self->_is_a( $file, 'Module::Generic::File' ) ? $file : Module::Generic::File::file( "$file" );
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_a($file, 'Module::Generic::File') ? : 0 0 0
324 # Basic error checking
325 0 ▶ if( !$file->exists )
Branch: 3 branches
BranchTrueFalseTotal
if (not $file->exists) { } 0 0 0
elsif (not $file->can_read) { } 0 0 0
elsif ($file->is_empty) { } 0 0 0
326 {
327 0 return( $self->error( "Json data file provided \"$file\" does not exist." ) );
328 }
329 elsif( !$file->can_read )
330 {
331 0 return( $self->error( "Json data file provided \"$file\" lacks enough permission to read." ) );
332 }
333 elsif( $file->is_empty )
334 {
335 0 return( $self->error( "Json data file provided \"$file\" is empty." ) );
336 }
337 0 my $json = $file->load_utf8;
338 0 ▶ return( $self->error( "Unable to open the public suffix json data file in read mode: $!" ) ) if( !defined( $json ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $json 0 0 0
339 0 ▶ return( $self->error( "No data found from public domain json file \"$file\"." ) ) if( !CORE::length( $json ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length $json 0 0 0
340 # try-catch
341 0 local $@;
342 my $ref = eval
343 0 {
344 0 my $j = JSON->new->relaxed;
345 0 return( $j->decode( $json ) );
346 };
347 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
348 {
349 0 return( $self->error( "An unexpected error occurred while trying to load json data of public suffixes: $@" ) );
350 }
351 0 ▶ if( ref( $ref->{suffixes} ) eq 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref->{"suffixes"} eq "HASH") 0 0 0
352 {
353 0 $PUBLIC_SUFFIX_DATA = $ref->{suffixes};
354 0 $self->suffixes( $ref->{suffixes} );
355 }
356 0 ▶ $ref->{meta} = {} if( ref( $ref->{meta} ) ne 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref->{"meta"} ne "HASH" 0 0 0
357 0 $self->meta( $ref->{metadata} );
358 0 return( $self );
359 }
360  
361 sub load_public_suffix
362 2 ▶{
Subroutine load_public_suffix: called CC=9 SCAR=22.8
Pod documented
363 2 my $self = shift( @_ );
364 2 ▶ my $file = shift( @_ ) || $self->file || return( $self->error( "No public suffix data file was provided." ) );
Condition40%2/5
shift @_ || $self->file || (return $self->error('No public suffix data file was provided.'))
l!l
20
shift @_ or $self->file
l!l&&r!l&&!r
200
MC/DC0%0/2
shift @_ || $self->file || (return $self->error('No public suffix data file was provided.'))
shift @_ $self->file
Truth table33%1/3
A or B
A= shift @_B= $self->file
ABresult
1X1
011
000
365 2 ▶ $file = $self->_is_a( $file, 'Module::Generic::File' ) ? $file : Module::Generic::File::file( "$file" );
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_a($file, 'Module::Generic::File') ? : 2 0 2
366 # Basic error checking
367 2 ▶ if( !$file->exists )
Branch: 3 branches
BranchTrueFalseTotal
if (not $file->exists) { } 0 2 2
elsif (not $file->can_read) { } 0 2 2
elsif ($file->is_empty) { } 0 2 2
368 {
369 0 return( $self->error( "Public suffix data file provided \"$file\" does not exist." ) );
370 }
371 elsif( !$file->can_read )
372 {
373 0 return( $self->error( "Public suffix data file provided \"$file\" lacks enough permission to read." ) );
374 }
375 elsif( $file->is_empty )
376 {
377 0 return( $self->error( "Public suffix data file provided \"$file\" is empty." ) );
378 }
379 2 ▶ $file->open( '<', { binmode => 'utf-8' }) || return( $self->error( "Unable to open the public suffix data file in read mode: ", $file->error ) );
Branch: 1 branch
BranchTrueFalseTotal
$file->open("<", {"binmode", "utf-8"}) or return $self->error("Unable to open the public suffix data file in read mode: ", $file->error) 2 0 2
380 2 my $ref = {};
381 $file->line(sub
382 33014 ▶ {
Subroutine __ANON__: called CC=8 SCAR=20.8
383 33014 my $l = shift( @_ );
384 33014 chomp( $l );
385 33014 $l =~ s,//.*$,,;
386 33014 $l =~ s,[[:blank:]\h]+$,,g;
387 33014 ▶ return(1) if( !CORE::length( $l ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length $l 12342 20672 33014
388 20672 my $orig;
389 20672 ▶ if( $l !~ /^[\x00-\x7f]*$/ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($l =~ /^[\x00-\x7f]*$/) 918 19754 20672
390 {
391 918 $orig = $l;
392 # try-catch
393 918 local $@;
394 $l = eval
395 918 {
396 918 Net::IDN::Encode::domain_to_ascii( $l );
397 };
398 918 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 918 918
399 {
400 0 return( $self->error( "An unexpected error occurred while parsing the public suffix data file content: $@" ) );
401 }
402 }
403 20672 my $is_neg = $l =~ s,^\!,,;
404 20672 my @labels = split( /\./, $l );
405 20672 my $h = $ref;
406 20672 foreach my $label ( reverse( @labels ) )
407 {
408 48270 ▶ $h = $h->{ $label } ||= {};
Condition100%2/2
$h->{$label} ||= {}
l!l
2616622104
MC/DC100%1/1
$h->{$label} ||= {}
$h->{$label}
Truth table100%2/2
A
A= $h->{$label}
Aresult
11
00
409 }
410 20672 ▶ $h->{_is_neg} = $is_neg if( $is_neg );
Branch: 1 branch
BranchTrueFalseTotal
if $is_neg 16 20656 20672
411 20672 ▶ $h->{_original} = $orig if( defined( $orig ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $orig 918 19754 20672
412 2 });
413  
414 2 $file->close;
415 # Although this is a private extension, it is still valid nevertheless, and is missing as of 2024-02-02
416 2 ▶ if( !CORE::exists( $ref->{test} ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ref->{"test"}) 2 0 2
417 {
418 2 $ref->{test} = {};
419 }
420 2 $self->suffixes( $ref );
421 2 $PUBLIC_SUFFIX_DATA = $ref;
422 2 return( $self );
423 }
424  
425 0 ▶sub meta { return( shift->_set_get_hash_as_mix_object( 'meta', @_ ) ); }
Subroutine meta: not called CC=1 SCAR=6.9
Pod documented
426  
427 0 ▶sub min_suffix { return( shift->_set_get_number( 'min_suffix', @_ ) ); }
Subroutine min_suffix: not called CC=1 SCAR=6.9
Pod documented
428  
429 0 ▶sub no_load { return( shift->_set_get_boolean( 'no_load', @_ ) ); }
Subroutine no_load: not called CC=1 SCAR=6.9
Pod documented
430  
431 sub save_as_json
432 2 ▶{
Subroutine save_as_json: called CC=11 SCAR=38.2
Pod documented
433 2 my $self = shift( @_ );
434 2 ▶ my $file = shift( @_ ) || $self->json_file || return( $self->error( "No json file was specified." ) );
Condition40%2/5
shift @_ || $self->json_file || (return $self->error('No json file was specified.'))
l!l
20
shift @_ or $self->json_file
l!l&&r!l&&!r
200
MC/DC0%0/2
shift @_ || $self->json_file || (return $self->error('No json file was specified.'))
shift @_ $self->json_file
Truth table33%1/3
A or B
A= shift @_B= $self->json_file
ABresult
1X1
011
000
435 2 ▶ $file = $self->_is_a( $file, 'Module::Generic::File' ) ? $file : Module::Generic::File::file( "$file" );
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_a($file, 'Module::Generic::File') ? : 2 0 2
436 2 my $data = $self->suffixes;
437 2 my $tz;
438 # DateTime::Lite::TimeZone will return an error if the local timezone is not set.
439 # try-catch
440 2 local $@;
441 $tz = eval
442 2 {
443 2 DateTime::Lite::TimeZone->new( name => 'local' );
444 };
445 2 ▶ if( $@ || !defined( $tz ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not defined $tz) 2 0 2
Condition33%1/3
$@ or not defined $tz
l!l&&r!l&&!r
020
MC/DC0%0/2
$@ or not defined $tz
$@ not defined $tz
Truth table33%1/3
A or not(B)
A= $@B= not defined $tz
ABresult
1X1
011
000
446 {
447 2 $tz = DateTime::TimeZone->new( name => 'UTC' );
448 }
449 0 my $dt_fmt = DateTime::Format::Lite->new(
450 pattern => '%FT%T%z',
451 locale => 'en_GB',
452 time_zone => $tz->name,
453 );
454 0 my $today = DateTime::Lite->now( time_zone => $tz, formatter => $dt_fmt );
455 0 my $meta = $self->meta;
456 my $ref =
457 {
458 metadata =>
459 {
460 created => $today->stringify,
461 module => 'Cookie::Domain',
462 ( $self->file && $self->file->exists ? ( db_last_modified => $self->file->mtime ) : () ),
463 0 ▶ ( $meta->{etag} ? ( etag => $meta->{etag} ) : () ),
Branch: 2 branches
BranchTrueFalseTotal
$self->file && $self->file->exists ? : 0 0 0
$meta->{'etag'} ? : 0 0 0
Condition0%0/3
$self->file and $self->file->exists
!ll&&!rl&&r
000
MC/DC0%0/2
$self->file and $self->file->exists
$self->file $self->file->exists
Truth table0%0/3
A and B
A= $self->fileB= $self->file->exists
ABresult
0X0
100
111
464 },
465 suffixes => $data
466 };
467 0 my $j = JSON->new->canonical->pretty->convert_blessed;
468 # try-catch
469 my $json = eval
470 0 {
471 0 $j->encode( $ref );
472 };
473 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
474 {
475 0 return( $self->error( "An error occurred while trying to save data to json file \"$file\": $@" ) );
476 }
477 0 ▶ $file->unload_utf8( $json ) ||
Branch: 1 branch
BranchTrueFalseTotal
$file->unload_utf8($json) or return $self->error(qq[Unable to write json data to file "$file": ], $file->error) 0 0 0
478 return( $self->error( "Unable to write json data to file \"$file\": ", $file->error ) );
479 0 return( $self );
480 }
481  
482 sub stat
483 0 ▶{
Subroutine stat: not called CC=26 SCAR=64.8
Pod documented
484 0 my $self = shift( @_ );
485 0 ▶ my $name = shift( @_ ) || return( $self->error( "No host name was provided" ) );
Condition0%0/2
shift @_ || (return $self->error('No host name was provided'))
l!l
00
MC/DC0%0/1
shift @_ || (return $self->error('No host name was provided'))
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
486 0 my $opts = $self->_get_args_as_hash( @_ );
487 0 ▶ $opts->{min_suffix} = $self->min_suffix if( !exists( $opts->{min_suffix} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts->{"min_suffix"} 0 0 0
488 0 my $idn;
489 # Punnycode
490 0 ▶ if( $name !~ /^[\x00-\x7f]*$/ )
Branch: 1 branch
BranchTrueFalseTotal
if (not $name =~ /^[\x00-\x7f]*$/) { } 0 0 0
491 {
492 0 $idn = $name;
493 0 $name = Net::IDN::Encode::domain_to_ascii( $name );
494 0 $name = lc( $name );
495 0 $name =~ s/^[[:blank:]\h]+|[[:blank:]\h]+$//g;
496 0 $name =~s/\.$//;
497 }
498 else
499 {
500 0 $name =~ s/^\.|\.$//g;
501 0 $name = lc( $name );
502 }
503 0 ▶ return( $self->error( "Malformed domain name \"$name\"" ) ) if( $name !~ /$DOMAIN_RE/ );
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /$Cookie::Domain::DOMAIN_RE/ 0 0 0
504 0 my $labels = $self->new_array( [split( /\./, $name )] );
505 # if( $labels->length == 1 && !$opts->{min_suffix} )
506 # {
507 # my $single = $labels->[0];
508 # my $name_out = defined( $idn ) ? Net::IDN::Encode::domain_to_unicode( $single ) : $single;
509 # return( Cookie::Domain::Result->new({ name => $name_out, sub => undef, suffix => '' }) );
510 # }
511  
512 0 my $any = {};
513 0 my $host = {};
514 0 my $expt = {};
515 0 my $ref = $self->suffixes;
516 0 my $def = $ref;
517 0 my $stack = [];
518 # The following algorithm is borrowed from IO-Socket-SSL
519 # for( my $i = 0; $i < scalar( @$labels ); $i++ )
520 # $labels->reverse->for(sub
521 0 my $reverse = $labels->reverse;
522 0 ▶ for( my $i = 0; $i < scalar( @$reverse ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$reverse) 0 0 0
523 {
524 0 my $label = $reverse->[$i];
525 # my( $i, $label ) = @_;
526 0 my $buff = [];
527 0 ▶ if( my $public_label_def = $def->{ $label } )
Branch: 2 branches
BranchTrueFalseTotal
if (my $public_label_def = $def->{$label}) { } 0 0 0
elsif (exists $def->{'*'}) { } 0 0 0
528 {
529 # name match, continue with next path element
530 0 push( @$buff, $public_label_def );
531 0 ▶ if( exists( $public_label_def->{_is_neg} ) && $public_label_def->{_is_neg} )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $public_label_def->{'_is_neg'} and $public_label_def->{'_is_neg'}) { } 0 0 0
Condition0%0/3
exists $public_label_def->{"_is_neg"} and $public_label_def->{"_is_neg"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $public_label_def->{"_is_neg"} and $public_label_def->{"_is_neg"}
exists $public_label_def->{"_is_neg"} $public_label_def->{"_is_neg"}
Truth table0%0/3
A and B
A= exists $public_label_def->{"_is_neg"}B= $public_label_def->{"_is_neg"}
ABresult
0X0
100
111
532 {
533 0 $expt->{ $i + 1 }->{ $i + 1 } = -1;
534 }
535 else
536 {
537 0 $host->{ $i + 1 }->{ $i + 1 } = 1;
538 }
539 }
540 elsif( exists( $def->{ '*' } ) )
541 {
542 0 my $public_label_def = $def->{ '*' };
543 0 push( @$buff, $public_label_def );
544 0 ▶ if( exists( $public_label_def->{_is_neg} ) && $public_label_def->{_is_neg} )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $public_label_def->{'_is_neg'} and $public_label_def->{'_is_neg'}) { } 0 0 0
Condition0%0/3
exists $public_label_def->{"_is_neg"} and $public_label_def->{"_is_neg"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $public_label_def->{"_is_neg"} and $public_label_def->{"_is_neg"}
exists $public_label_def->{"_is_neg"} $public_label_def->{"_is_neg"}
Truth table0%0/3
A and B
A= exists $public_label_def->{"_is_neg"}B= $public_label_def->{"_is_neg"}
ABresult
0X0
100
111
545 {
546 0 $expt->{ $i + 1 }->{ $i + 1 } = -1;
547 }
548 else
549 {
550 0 $any->{ $i + 1 }->{ $i + 1 } = 1;
551 }
552 }
553  
554 9 ▶ no warnings 'exiting';
Subroutine BEGIN: called CC=1 SCAR=0.0
555 LABEL:
556 # We found something
557 0 ▶ if( @$buff )
Branch: 1 branch
BranchTrueFalseTotal
if (@$buff) 0 0 0
558 {
559 # take out the one we just added
560 0 $def = shift( @$buff );
561 # if we are circling within the next_choice loop, add the previous step to $stack
562 0 ▶ push( @$stack, [ $buff, $i ] ) if( @$buff );
Branch: 1 branch
BranchTrueFalseTotal
if @$buff 0 0 0
563 # go deeper
564 0 next;
565 # The following works too by the way, but let's keep it traditional
566 # return(1);
567 }
568  
569 # We did not find anything, so we backtrack
570 0 ▶ last if( !scalar( @$stack ) );
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$stack 0 0 0
571 # The following works too by the way, but let's keep it traditional
572 # return if( !scalar( @$stack ) );
573 # Recall our last entry
574 0 ( $buff, $_[0] ) = @{ pop( @$stack ) };
575 0 goto LABEL;
576 # });
577 }
578  
579 # remove all exceptions from wildcards
580 0 ▶ delete( @$any{ keys( %$expt ) } ) if( scalar( keys( %$expt ) ) );
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %$expt 0 0 0
581 # get longest match
582 0 my( $len ) = sort{ $b <=> $a } (
583 0 keys( %$any ), keys( %$host ), map{ $_-1 } keys( %$expt )
584 );
585 0 ▶ $len = $opts->{min_suffix} if( !defined( $len ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $len 0 0 0
586 0 ▶ $len += int( $opts->{add} ) if( $opts->{add} );
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"add"} 0 0 0
587 0 my $suffix;
588 my $sub;
589 0 ▶ if( $len < $labels->length )
Branch: 2 branches
BranchTrueFalseTotal
if ($len < $labels->length) { } 0 0 0
elsif ($len > 0) { } 0 0 0
590 {
591 0 $suffix = $self->new_array( [ $labels->splice( -$len, $len ) ] );
592 }
593 elsif( $len > 0 )
594 {
595 0 $suffix = $labels;
596 0 $labels = $self->new_array;
597 }
598 else
599 {
600 0 $suffix = $self->new_array;
601 }
602 0 ▶ if( !$suffix->length )
Branch: 1 branch
BranchTrueFalseTotal
unless ($suffix->length) 0 0 0
603 {
604 0 ▶ if( want( 'OBJECT' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (want('OBJECT')) { } 0 0 0
605 {
606 0 rreturn( Module::Generic::Null->new );
607 }
608 else
609 {
610 0 return( '' );
611 }
612 }
613 0 $suffix = $suffix->join( '.' );
614 0 $name = $labels->pop;
615 0 ▶ $sub = $labels->join( '.' ) if( $labels->length );
Branch: 1 branch
BranchTrueFalseTotal
if $labels->length 0 0 0
616 0 ▶ if( defined( $idn ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $idn) 0 0 0
617 {
618 0 $suffix = Net::IDN::Encode::domain_to_unicode( $suffix );
619 0 ▶ $name = Net::IDN::Encode::domain_to_unicode( $name ) if( defined( $name ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 0 0 0
620 0 ▶ $sub = Net::IDN::Encode::domain_to_unicode( $sub ) if( defined( $sub ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $sub 0 0 0
621 }
622 0 return(Cookie::Domain::Result->new({ name => $name, sub => $sub, suffix => $suffix }));
623 }
624  
625 4 ▶sub suffixes { return( shift->_set_get_hash_as_mix_object( 'suffixes', @_ ) ); }
Subroutine suffixes: called CC=1 SCAR=0.0
Pod documented
626  
627 # NOTE: Cookie::Domain::Result class
628 {
629 package
630 Cookie::Domain::Result;
631 BEGIN
632 9 ▶ {
Subroutine BEGIN: called CC=1 SCAR=0.0
633 9 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
634 9 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
635 9 ▶ use parent qw( Module::Generic::Hash );
Subroutine BEGIN: called CC=1 SCAR=0.0
636 9 ▶ use Wanted;
Subroutine BEGIN: called CC=1 SCAR=0.0
637 9 our $VERSION = 'v0.1.0';
638 };
639  
640 sub domain
641 0 ▶ {
Subroutine domain: not called CC=3 SCAR=24.8
642 0 my $self = shift( @_ );
643 0 ▶ if( !$self->name->length && !$self->suffix->length )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->name->length or $self->suffix->length) 0 0 0
Condition0%0/3
$self->name->length or $self->suffix->length
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->name->length or $self->suffix->length
$self->name->length $self->suffix->length
Truth table0%0/3
A or B
A= $self->name->lengthB= $self->suffix->length
ABresult
1X1
011
000
644 {
645 0 return( Module::Generic::Scalar->new( '' ) );
646 }
647 0 return( $self->name->join( '.', $self->suffix ) );
648 }
649  
650 0 ▶ sub name { return( shift->_set_get_scalar_as_object( 'name', @_ ) ); }
Subroutine name: not called CC=1 SCAR=6.9
651  
652 0 ▶ sub sub { return( shift->_set_get_scalar_as_object( 'sub', @_ ) ); }
Subroutine sub: not called CC=1 SCAR=6.9
653  
654 0 ▶ sub suffix { return( shift->_set_get_scalar_as_object( 'suffix', @_ ) ); }
Subroutine suffix: not called CC=1 SCAR=6.9
655 }
656  
657 9 1;
658 # NOTE: POD
659 __END__
« Cookie/Jar.pm ↑ Summary Cookie.pm »