lib/Module/Generic/File/IO.pm

filter: Statementstmt 67.8% 211 / 311 Branchbran 51.6% 63 / 122 Conditioncond 41.0% 48 / 117 MC/DCmcdc 15.8% 10 / 63 Subroutinesub 54.3% 44 / 81 Podpod 93.7% 60 / 64 totaltotal 57.5% 436 / 758 CC 105 SCAR 28.8
CC
105
Cov
59%
new
88.8
THAW
33.0
wraphandle
30.0
CRAP 17.8
« lib/Module/Generic/Iterator.pm ↑ Summary lib/Module/Generic/Hash.pm »
1 ##----------------------------------------------------------------------------
2 ## Module Generic - ~/lib/Module/Generic/File/IO.pm
3 ## Version v0.2.1
4 ## Copyright(c) 2025 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2022/04/26
7 ## Modified 2026/03/14
8 ## All rights reserved
9 ##
10 ## This program is free software; you can redistribute it and/or modify it
11 ## under the same terms as Perl itself.
12 ##----------------------------------------------------------------------------
13 package Module::Generic::File::IO;
14 BEGIN
15 14 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
16 14 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 14 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 14 warnings::register_categories( 'Module::Generic' );
19 14 ▶ use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 14 ▶ use Fcntl qw( :DEFAULT :flock :seek );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 14 ▶ use IO::File ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 14 ▶ use parent qw( Module::Generic IO::File );
Subroutine BEGIN: called CC=1 SCAR=0.0
23 14 ▶ use vars qw( $VERSION @EXPORT $THAW_REOPENS_FILE );
Subroutine BEGIN: called CC=1 SCAR=0.0
24 14 ▶ use Module::Generic::Global ':const';
Subroutine BEGIN: called CC=1 SCAR=0.0
25 14 ▶ use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26 14 ▶ use Wanted;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 14 our @EXPORT = grep( /^(?:O_|F_GETFL|F_SETFL)/, @Fcntl::EXPORT );
28 14 push( @EXPORT, @{$Fcntl::EXPORT_TAGS{flock}}, @{$Fcntl::EXPORT_TAGS{seek}} );
29 14 our @EXPORT_OK = qw( wraphandle );
30 14 our $THAW_REOPENS_FILE = 1;
31 14 our $VERSION = 'v0.2.1';
32 };
33  
34 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 sub new
38 35 ▶{
Subroutine new: called CC=17 SCAR=44.9
Pod documented
39 35 my $this = shift( @_ );
40 35 ▶ my $class = ( ref( $this ) || $this );
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0350
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
41 35 my $opts = {};
42 35 ▶ $opts = pop( @_ ) if( ref( $_[-1] ) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "HASH" 0 35 35
43 35 my $args = [@_];
44 35 my $self;
45 # try-catch
46 35 local $@;
47 eval
48 35 {
49 35 $self = $class->IO::File::new( @_ );
50 };
51 35 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 35 35
52 {
53 0 return( $this->error( "Error trying to open file \"", $_[0], "\" with arguments: '", join( "', '", @_[1..$#_] ), "': $@" ) );
54 }
55 35 ▶ $self or return( $this->error( "Unable to open file \"", $_[0], "\" with arguments: '", join( "', '", @_[1..$#_] ), "': $!" ) );
Branch: 1 branch
BranchTrueFalseTotal
$self or return $this->error("Unable to open file \"", $_[0], "\" with arguments: '", join("', '", @_[1 .. $#_]), "': $!") 35 0 35
56  
57 35 ▶ if( exists( $opts->{fileno} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts->{"fileno"} and defined $opts->{"fileno"} and length $opts->{"fileno"}) 0 35 35
Condition33%2/6
exists $opts->{"fileno"} and defined $opts->{"fileno"} and length $opts->{"fileno"}
!ll&&!rl&&r
3500
exists $opts->{"fileno"} and defined $opts->{"fileno"}
!ll&&!rl&&r
3500
MC/DC0%0/3
exists $opts->{"fileno"} and defined $opts->{"fileno"} and length $opts->{"fileno"}
exists $opts->{"fileno"} defined $opts->{"fileno"} length $opts->{"fileno"}
Truth table25%1/4
A and B and C
A= exists $opts->{"fileno"}B= defined $opts->{"fileno"}C= length $opts->{"fileno"}
ABCresult
0XX0
10X0
1100
1111
58 defined( $opts->{fileno} ) &&
59 length( $opts->{fileno} ) )
60 {
61 0 my $fileno = CORE::delete( $opts->{fileno} );
62 # > +<, etc and r, w, r+
63 0 my $mode = 'r';
64 0 ▶ $mode = CORE::delete( $opts->{mode} ) if( exists( $opts->{mode} ) && defined( $opts->{mode} ) && length( $opts->{mode} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts->{"mode"} and defined $opts->{"mode"} and length $opts->{"mode"} 0 0 0
Condition0%0/6
exists $opts->{"mode"} and defined $opts->{"mode"} and length $opts->{"mode"}
!ll&&!rl&&r
000
exists $opts->{"mode"} and defined $opts->{"mode"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $opts->{"mode"} and defined $opts->{"mode"} and length $opts->{"mode"}
exists $opts->{"mode"} defined $opts->{"mode"} length $opts->{"mode"}
Truth table0%0/4
A and B and C
A= exists $opts->{"mode"}B= defined $opts->{"mode"}C= length $opts->{"mode"}
ABCresult
0XX0
10X0
1100
1111
65 0 my $rv;
66 # try-catch
67 0 local $@;
68 eval
69 0 {
70 0 $rv = $self->fdopen( $fileno, $mode );
71 };
72 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
73 {
74 0 return( $this->error( "Error trying to open file \"", $_[0], "\" with arguments: '", join( "', '", @_[1..$#_] ), "': $@" ) );
75 }
76 0 ▶ $rv or return( $this->error( "Unable to fdopen using file descriptor ${fileno} and mode ${mode}: $!" ) );
Branch: 1 branch
BranchTrueFalseTotal
$rv or return $this->error("Unable to fdopen using file descriptor $fileno and mode ${mode}: $!") 0 0 0
77 }
78  
79 35 *$self = { args => $args };
80 35 ▶ if( Wanted::want( 'OBJECT' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (Wanted::want("OBJECT")) 0 35 35
81 {
82 0 return( $self->init( $opts ) );
83 }
84 35 my $new = $self->init( @_ );
85 35 ▶ if( !defined( $new ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $new) 0 35 35
86 {
87 # If we are called on an object, we hand it the error so the caller can check it using the object:
88 # my $new = $old->new || die( $old->error );
89 0 ▶ if( $self->_is_object( $this ) && $this->can( 'pass_error' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_object($this) and $this->can('pass_error')) { } 0 0 0
Condition0%0/3
$self->_is_object($this) and $this->can("pass_error")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_is_object($this) and $this->can("pass_error")
$self->_is_object($this) $this->can("pass_error")
Truth table0%0/3
A and B
A= $self->_is_object($this)B= $this->can("pass_error")
ABresult
0X0
100
111
90 {
91 0 return( $this->pass_error( $self->error ) );
92 }
93 else
94 {
95 0 return( $self->pass_error );
96 }
97 };
98 35 return( $new );
99 }
100  
101 sub init
102 37 ▶{
Subroutine init: called CC=3 SCAR=11.0
Pod documented
103 37 my $self = shift( @_ );
104 37 my $opts = {};
105 37 ▶ $opts = pop( @_ ) if( ref( $_[-1] ) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "HASH" 1 36 37
106 37 *$self->{_init_strict_use_sub} = 1;
107 37 ▶ $self->Module::Generic::init( $opts ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->Module::Generic::init($opts) or return $self->pass_error 37 0 37
108 37 return( $self );
109 }
110  
111 sub args
112 2 ▶{
Subroutine args: called CC=1 SCAR=0.0
Pod documented
113 2 my $self = shift( @_ );
114 2 return( *$self->{args} );
115 }
116  
117 # This class does not convert to an HASH
118 0 ▶sub as_hash { return( $_[0] ); }
Subroutine as_hash: not called CC=1 SCAR=6.9
Pod documented
119  
120 30 ▶sub autoflush { return( shift->_filehandle_method( 'autoflush', @_ ) ); }
Subroutine autoflush: called CC=1 SCAR=0.0
Pod documented
121  
122 7 ▶sub binmode { return( shift->_filehandle_method( 'binmode', @_ ) ); }
Subroutine binmode: called CC=1 SCAR=0.0
Pod documented
123  
124 0 ▶sub blocking { return( shift->_filehandle_method( 'blocking', @_ ) ); }
Subroutine blocking: not called CC=1 SCAR=6.9
Pod documented
125  
126 sub can_read
127 0 ▶{
Subroutine can_read: not called CC=4 SCAR=30.0
Pod documented
128 0 my $self = shift( @_ );
129 0 my $dummy = 0;
130 0 my $flags = $self->fcntl( F_GETFL, $dummy );
131 0 ▶ return( $self->error( $! ) ) if( !defined( $flags ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flags 0 0 0
132 0 ▶ return(1) if( ( $flags & O_RDWR ) );
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 2 0 0 0
133 0 ▶ return(1) if( ( $flags & O_RDONLY ) == O_RDONLY );
Branch: 1 branch
BranchTrueFalseTotal
if ($flags & 0) == 0 0 0 0
134 # or, extracting the mode from the bits
135 # return(1) if( !( $flags & O_ACCMODE ) );
136 0 return(0);
137 }
138  
139 sub can_write
140 0 ▶{
Subroutine can_write: not called CC=2 SCAR=17.9
Pod documented
141 0 my $self = shift( @_ );
142 0 my $dummy = 0;
143 0 my $flags = $self->fcntl( F_GETFL, $dummy );
144 0 ▶ return( $self->error( $! ) ) if( !defined( $flags ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flags 0 0 0
145 0 return( $flags & ( O_APPEND | O_WRONLY | O_CREAT | O_RDWR ) );
146 }
147  
148 sub close
149 37 ▶{
Subroutine close: called CC=4 SCAR=13.9
Pod documented
150 37 my $self = shift( @_ );
151 37 my $fd = $self->fileno;
152 37 my $rv = $self->_filehandle_method( 'close', @_ );
153 37 ▶ if( $rv && $fd )
Branch: 1 branch
BranchTrueFalseTotal
if ($rv and $fd) 36 1 37
Condition66%2/3
$rv and $fd
!ll&&!rl&&r
1036
MC/DC50%1/2
$rv and $fd
$rv $fd
Truth table66%2/3
A and B
A= $rvB= $fd
ABresult
0X0
100
111
154 {
155 36 my $repo_key = $fd;
156 36 ▶ my $repo = Module::Generic::Global->new( 'fd_locks' => CORE::ref( $self ), key => $repo_key ) ||
Condition50%1/2
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key) || (return $self->pass_error('Module::Generic::Global'->error))
l!l
360
MC/DC0%0/1
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key) || (return $self->pass_error('Module::Generic::Global'->error))
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key)
Truth table50%1/2
A
A= 'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key)
Aresult
11
00
157 return( $self->pass_error( Module::Generic::Global->error ) );
158 # Clear any lock state
159 36 $repo->remove;
160 # Clear instance lock state
161 36 $self->locked(0);
162 }
163 37 return( $rv );
164 }
165  
166 # sub constant { return( shift->_filehandle_method( 'constant', @_ ) ); }
167  
168 2 ▶sub eof { return( shift->_filehandle_method( 'eof', @_ ) ); }
Subroutine eof: called CC=1 SCAR=0.0
Pod documented
169  
170 # sub fcntl { return( shift->_filehandle_method( 'fcntl', @_ ) ); }
171 sub fcntl
172 105 ▶{
Subroutine fcntl: called CC=3 SCAR=11.3
Pod documented
173 105 my $self = shift( @_ );
174 105 ▶ return( $self->error( 'usage: $io->fcntl( OP, VALUE );' ) ) if( scalar( @_ ) != 2 );
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ != 2 0 105 105
175 105 my( $op, $value ) = @_;
176 105 my $rv;
177 # try-catch
178 105 local $@;
179 eval
180 105 {
181 105 $rv = CORE::fcntl( *$self, $op, $value );
182 };
183 105 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 105 105
184 {
185 0 return( $self->error( "An unexpected error occurred while trying to call fcntl with function '$op' and value '$value': $@" ) );
186 }
187 105 return( $rv );
188 }
189  
190 0 ▶sub fdopen { return( shift->_filehandle_method( 'fdopen', @_ ) ); }
Subroutine fdopen: not called CC=1 SCAR=6.9
Pod documented
191  
192 174 ▶sub fileno { return( shift->_filehandle_method( 'fileno', @_ ) ); }
Subroutine fileno: called CC=1 SCAR=0.0
Pod documented
193  
194 sub flags
195 0 ▶{
Subroutine flags: not called CC=1 SCAR=6.9
Pod documented
196 0 my $self = shift( @_ );
197 0 my $dummy;
198 # return( $self->fcntl( F_GETFL, $dummy ) );
199 0 return( CORE::fcntl( *$self, F_GETFL, $dummy ) );
200 }
201  
202 sub flock
203 33 ▶{
Subroutine flock: called CC=14 SCAR=28.1
Pod documented
204 33 my $self = shift( @_ );
205 33 ▶ return( $self->error( 'usage: $io->flock( OPERATION );' ) ) if( scalar( @_ ) != 1 );
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ != 1 0 33 33
206 33 my $op = shift( @_ );
207  
208 33 my $fd = $self->fileno;
209 33 my $repo;
210 33 ▶ if( $fd )
Branch: 1 branch
BranchTrueFalseTotal
if ($fd) 33 0 33
211 {
212 33 my $repo_key = $fd;
213 33 ▶ $repo = Module::Generic::Global->new( 'fd_locks' => CORE::ref( $self ), key => $repo_key ) ||
Condition50%1/2
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key) || (return $self->pass_error('Module::Generic::Global'->error))
l!l
330
MC/DC0%0/1
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key) || (return $self->pass_error('Module::Generic::Global'->error))
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key)
Truth table50%1/2
A
A= 'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key)
Aresult
11
00
214 return( $self->pass_error( Module::Generic::Global->error ) );
215 33 my $current_state = $repo->get;
216 # There is already a lock, and it is not an unlock operation, so we warn about it, and provides details.
217 33 ▶ if( !( $op & LOCK_UN ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $op & 8 and defined $current_state and ref($current_state // "") eq "HASH") 1 32 33
Condition75%6/8
not $op & 8 and defined $current_state and ref($current_state // "") eq "HASH"
!ll&&!rl&&r
3201
not $op & 8 and defined $current_state
!ll&&!rl&&r
15171
$current_state // ""
l!l
10
MC/DC66%2/3
not $op & 8 and defined $current_state and ref($current_state // "") eq "HASH"
not $op & 8 defined $current_state $current_state
Truth table75%3/4
not(A) and B and C
A= not $op & 8B= defined $current_stateC= $current_state
ABCresult
0XX0
10X0
1100
1111
218 defined( $current_state ) &&
219 CORE::ref( $current_state // '' ) eq 'HASH' )
220 {
221 1 ▶ warn( "The process with thread ID $current_state->{tid} and pid $current_state->{pid} already holds a lock on the file handle with flags $current_state->{flags}, and registered from class ", $current_state->{caller}->[0], " at line ", $current_state->{caller}->[2], "." ) if( $self->_is_warnings_enabled( 'Module::Generic' ) );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_warnings_enabled("Module::Generic") 0 1 1
222 }
223 }
224 # try-catch
225 33 local $@;
226 my $rv = eval
227 33 {
228 33 CORE::flock( *$self, $op );
229 };
230 33 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 33 33
231 {
232 0 return( $self->error( "An unexpected error occurred while trying to call flock with operation '$op': $@" ) );
233 }
234 33 ▶ if( $rv && defined( $repo ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($rv and defined $repo) 33 0 33
Condition33%1/3
$rv and defined $repo
!ll&&!rl&&r
0033
MC/DC0%0/2
$rv and defined $repo
$rv defined $repo
Truth table33%1/3
A and B
A= $rvB= defined $repo
ABresult
0X0
100
111
235 {
236 33 ▶ if( $op & LOCK_UN )
Branch: 1 branch
BranchTrueFalseTotal
if ($op & 8) { } 15 18 33
237 {
238 15 $repo->remove;
239 }
240 else
241 {
242 # We possibly overwrite any previous lock information if the user executes a double lock, but at least we would have warned about it upper.
243 18 my $caller = [caller];
244 18 ▶ $repo->set({
Branch: 1 branch
BranchTrueFalseTotal
&HAS_THREADS() ? : 0 18 18
245 flags => $op,
246 pid => $$,
247 tid => ( HAS_THREADS ? threads->tid() : 0 ),
248 timestamp => time(),
249 'caller' => $caller,
250 });
251 }
252 }
253 33 return( $rv );
254 }
255  
256 9 ▶sub flush { return( shift->_filehandle_method( 'flush', @_ ) ); }
Subroutine flush: called CC=1 SCAR=0.0
Pod documented
257  
258 0 ▶sub format_formfeed { return( shift->_filehandle_method( 'format_formfeed', @_ ) ); }
Subroutine format_formfeed: not called CC=1 SCAR=6.9
Pod documented
259  
260 0 ▶sub format_line_break_characters { return( shift->_filehandle_method( 'format_line_break_characters', @_ ) ); }
Subroutine format_line_break_characters: not called CC=1 SCAR=6.9
Pod documented
261  
262 0 ▶sub format_lines_left { return( shift->_filehandle_method( 'format_lines_left', @_ ) ); }
Subroutine format_lines_left: not called CC=1 SCAR=6.9
Pod documented
263  
264 0 ▶sub format_lines_per_page { return( shift->_filehandle_method( 'format_lines_per_page', @_ ) ); }
Subroutine format_lines_per_page: not called CC=1 SCAR=6.9
Pod documented
265  
266 0 ▶sub format_name { return( shift->_filehandle_method( 'format_name', @_ ) ); }
Subroutine format_name: not called CC=1 SCAR=6.9
Pod documented
267  
268 0 ▶sub format_page_number { return( shift->_filehandle_method( 'format_page_number', @_ ) ); }
Subroutine format_page_number: not called CC=1 SCAR=6.9
Pod documented
269  
270 0 ▶sub format_top_name { return( shift->_filehandle_method( 'format_top_name', @_ ) ); }
Subroutine format_top_name: not called CC=1 SCAR=6.9
Pod documented
271  
272 0 ▶sub format_write { return( shift->_filehandle_method( 'format_write', @_ ) ); }
Subroutine format_write: not called CC=1 SCAR=6.9
Pod documented
273  
274 0 ▶sub formline { return( shift->_filehandle_method( 'formline', @_ ) ); }
Subroutine formline: not called CC=1 SCAR=6.9
Pod documented
275  
276 2 ▶sub getc { return( shift->_filehandle_method( 'getc', @_ ) ); }
Subroutine getc: called CC=1 SCAR=0.0
Pod documented
277  
278 8 ▶sub getline { return( shift->_filehandle_method( 'getline', @_ ) ); }
Subroutine getline: called CC=1 SCAR=0.0
Pod documented
279  
280 11 ▶sub getlines { return( shift->_filehandle_method( 'getlines', @_ ) ); }
Subroutine getlines: called CC=1 SCAR=0.0
Pod documented
281  
282 0 ▶sub getpos { return( shift->_filehandle_method( 'getpos', @_ ) ); }
Subroutine getpos: not called CC=1 SCAR=6.9
Pod documented
283  
284 0 ▶sub input_line_number { return( shift->_filehandle_method( 'input_line_number', @_ ) ); }
Subroutine input_line_number: not called CC=1 SCAR=6.9
Pod documented
285  
286 0 ▶sub input_record_separator { return( shift->_filehandle_method( 'input_record_separator', @_ ) ); }
Subroutine input_record_separator: not called CC=1 SCAR=6.9
Pod documented
287  
288 0 ▶sub ioctl { return( shift->_filehandle_method( 'ioctl', @_ ) ); }
Subroutine ioctl: not called CC=1 SCAR=6.9
Pod documented
289  
290 sub lock_state
291 0 ▶{
Subroutine lock_state: not called CC=4 SCAR=26.1
Pod documented
292 0 my $self = shift( @_ );
293 0 my $fd;
294 {
295 # There could be no file descriptor, and trying to access would trigger an error
296 0 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.2
297 0 $fd = $self->fileno;
298 }
299 0 ▶ if( $fd )
Branch: 1 branch
BranchTrueFalseTotal
if ($fd) 0 0 0
300 {
301 0 my $repo_key = $fd;
302 0 ▶ my $repo = Module::Generic::Global->new( 'fd_locks' => CORE::ref( $self ), key => $repo_key ) ||
Condition0%0/2
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key) || (return $self->pass_error('Module::Generic::Global'->error))
l!l
00
MC/DC0%0/1
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key) || (return $self->pass_error('Module::Generic::Global'->error))
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key)
Truth table0%0/2
A
A= 'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key)
Aresult
11
00
303 return( $self->pass_error( Module::Generic::Global->error ) );
304 0 my $repo_data = $repo->get;
305 # undef is reserved for errors, so we return instead an empty string.
306 0 ▶ return( $repo_data // '' );
Condition0%0/2
$repo_data // ""
l!l
00
MC/DC0%0/1
$repo_data // ""
$repo_data
Truth table0%0/2
A
A= $repo_data
Aresult
11
00
307 }
308 0 return( '' );
309 }
310  
311 sub locked
312 79 ▶{
Subroutine locked: called CC=15 SCAR=30.1
Pod documented
313 79 my $self = shift( @_ );
314 79 my $flags = $self->_set_get_scalar( 'locked', @_ );
315 # File is not opened, so it cannot be locked
316 79 ▶ $self->opened || return(0);
Branch: 1 branch
BranchTrueFalseTotal
$self->opened or return 0 43 36 79
317 # Mutator mode, not checking
318 43 ▶ return( $flags ) if( scalar( @_ ) );
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ 0 43 43
319 43 my $fd = $self->fileno;
320 43 ▶ return( $self->error( "No file descriptor found for this filehandle." ) ) if( !defined( $fd ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fd 0 43 43
321 43 my $repo_key = $fd;
322 43 ▶ my $repo = Module::Generic::Global->new( 'fd_locks' => CORE::ref( $self ), key => $repo_key ) ||
Condition50%1/2
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key) || (return $self->pass_error('Module::Generic::Global'->error))
l!l
430
MC/DC0%0/1
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key) || (return $self->pass_error('Module::Generic::Global'->error))
'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key)
Truth table50%1/2
A
A= 'Module::Generic::Global'->new('fd_locks', ref $self, 'key', $repo_key)
Aresult
11
00
323 return( $self->pass_error( Module::Generic::Global->error ) );
324 43 my $current_state = $repo->get;
325 # We first check if we have any fd locks repository data
326 43 ▶ if( defined( $current_state ) && CORE::ref( $current_state // '' ) eq 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $current_state and ref($current_state // "") eq "HASH") 19 24 43
Condition60%3/5
defined $current_state and ref($current_state // "") eq "HASH"
!ll&&!rl&&r
24019
$current_state // ""
l!l
190
MC/DC50%1/2
defined $current_state and ref($current_state // "") eq "HASH"
defined $current_state $current_state
Truth table66%2/3
A and B
A= defined $current_stateB= $current_state
ABresult
0X0
100
111
327 {
328 # Here whatever $current_state->{pid} is, it necessarily has to be the same as $$ since Module::Generic::File::IO file descriptors change per process, and our key repo is a file descriptor.
329 19 ▶ return( $current_state->{flags} || 0E0 );
Condition50%1/2
$current_state->{'flags'} || 0.0
l!l
190
MC/DC0%0/1
$current_state->{'flags'} || 0.0
$current_state->{'flags'}
Truth table50%1/2
A
A= $current_state->{'flags'}
Aresult
11
00
330 }
331  
332 # We could not find any repository data, so we check using fcntl
333 # Try fcntl with F_GETLK (POSIX systems)
334 24 my $is_posix = ( $^O =~ /^(linux|darwin|freebsd|openbsd|netbsd|solaris|aix)$/i );
335 24 ▶ if( $is_posix )
Branch: 1 branch
BranchTrueFalseTotal
if ($is_posix) 24 0 24
336 {
337 # Exclusive lock probe
338 # struct flock layout varies by platform — q (int64) is unavailable on 32-bit Perls
339 # - 64-bit systems: l_type(s), l_whence(s), l_start(q), l_len(q), l_pid(i)
340 # - 32-bit systems: l_type(s), l_whence(s), l_start(l), l_len(l), l_pid(i)
341 # We use Config to determine which pack template to use.
342 24 my $lock;
343 24 ▶ if( $Config{use64bitint} )
Branch: 1 branch
BranchTrueFalseTotal
if ($Module::Generic::File::IO::Config{'use64bitint'}) { } 24 0 24
344 {
345 24 $lock = pack( 'ssqqqi', F_WRLCK, SEEK_SET, 0, 0, 0, 0 );
346 }
347 else
348 {
349 0 $lock = pack( 'sslli', F_WRLCK, SEEK_SET, 0, 0, 0, 0 );
350 }
351 my $rv = eval
352 24 {
353 24 $self->fcntl( F_GETLK, $lock );
354 };
355 24 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 24 24
356 {
357 0 return( $self->error( "Unable to check lock status for file handle: $@" ) );
358 }
359  
360 24 ▶ unless( defined( $rv ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rv) 0 24 24
361 {
362 0 return( $self->error( "Unable to check lock status for file handle: $!" ) );
363 }
364 24 my( $type ) = unpack( 's', $lock );
365 24 ▶ if( $type != F_UNLCK )
Branch: 1 branch
BranchTrueFalseTotal
if ($type != 2) 24 0 24
366 {
367 # Locked, return flags or true
368 24 ▶ return( $flags || 0E0 );
Condition50%1/2
$flags || 0.0
l!l
024
MC/DC0%0/1
$flags || 0.0
$flags
Truth table50%1/2
A
A= $flags
Aresult
11
00
369 }
370 }
371 # Otherwise, simply return the state we have, which may be undef
372 0 return( $flags );
373 }
374  
375 0 ▶sub new_from_fd { return( shift->_filehandle_method( 'new_from_fd', @_ ) ); }
Subroutine new_from_fd: not called CC=1 SCAR=6.9
Pod documented
376  
377 0 ▶sub new_tmpfile { return( shift->_filehandle_method( 'new_tmpfile', @_ ) ); }
Subroutine new_tmpfile: not called CC=1 SCAR=6.9
Pod documented
378  
379 1409 ▶sub opened { return( shift->_filehandle_method( 'opened', @_ ) ); }
Subroutine opened: called CC=1 SCAR=0.0
Pod documented
380  
381 0 ▶sub output_field_separator { return( shift->_filehandle_method( 'output_field_separator', @_ ) ); }
Subroutine output_field_separator: not called CC=1 SCAR=6.9
Pod documented
382  
383 0 ▶sub output_record_separator { return( shift->_filehandle_method( 'output_record_separator', @_ ) ); }
Subroutine output_record_separator: not called CC=1 SCAR=6.9
Pod documented
384  
385 1043 ▶sub print { return( shift->_filehandle_method( 'print', @_ ) ); }
Subroutine print: called CC=1 SCAR=0.0
Pod documented
386  
387 1 ▶sub printf { return( shift->_filehandle_method( 'printf', @_ ) ); }
Subroutine printf: called CC=1 SCAR=0.0
Pod documented
388  
389 0 ▶sub printflush { return( shift->_filehandle_method( 'printflush', @_ ) ); }
Subroutine printflush: not called CC=1 SCAR=6.9
Pod documented
390  
391 6 ▶sub read { return( shift->_filehandle_method( 'read', @_ ) ); }
Subroutine read: called CC=1 SCAR=0.0
Pod documented
392  
393 0 ▶sub say { return( shift->_filehandle_method( 'say', @_ ) ); }
Subroutine say: not called CC=1 SCAR=6.9
Pod documented
394  
395 49 ▶sub seek { return( shift->_filehandle_method( 'seek', @_ ) ); }
Subroutine seek: called CC=1 SCAR=0.0
Pod documented
396  
397 sub select
398 0 ▶{
Subroutine select: not called CC=3 SCAR=24.8
Pod documented
399 0 my $self = shift( @_ );
400 0 ▶ return( $self->error( 'usage: $io->select();' ) ) if( scalar( @_ ) );
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ 0 0 0
401 0 my $rv;
402 # try-catch
403 0 local $@;
404 eval
405 0 {
406 0 $rv = CORE::select( *$self );
407 };
408 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
409 {
410 0 return( $self->error( "An unexpected error occurred while trying to call select: $@" ) );
411 }
412 0 return( $rv );
413 }
414  
415 0 ▶sub setpos { return( shift->_filehandle_method( 'setpos', @_ ) ); }
Subroutine setpos: not called CC=1 SCAR=6.9
Pod documented
416  
417 0 ▶sub stat { return( shift->_filehandle_method( 'stat', @_ ) ); }
Subroutine stat: not called CC=1 SCAR=6.9
Pod documented
418  
419 8 ▶sub sync { return( shift->_filehandle_method( 'sync', @_ ) ); }
Subroutine sync: called CC=1 SCAR=0.0
Pod documented
420  
421 0 ▶sub sysopen { return( shift->_filehandle_method( 'sysopen', @_ ) ); }
Subroutine sysopen: not called CC=1 SCAR=6.9
Pod documented
422  
423 0 ▶sub sysread { return( shift->_filehandle_method( 'sysread', @_ ) ); }
Subroutine sysread: not called CC=1 SCAR=6.9
Pod documented
424  
425 0 ▶sub sysseek { return( shift->_filehandle_method( 'sysseek', @_ ) ); }
Subroutine sysseek: not called CC=1 SCAR=6.9
Pod documented
426  
427 0 ▶sub syswrite { return( shift->_filehandle_method( 'syswrite', @_ ) ); }
Subroutine syswrite: not called CC=1 SCAR=6.9
Pod documented
428  
429 29 ▶sub tell { return( shift->_filehandle_method( 'tell', @_ ) ); }
Subroutine tell: called CC=1 SCAR=0.0
Pod documented
430  
431 13 ▶sub truncate { return( shift->_filehandle_method( 'truncate', @_ ) ); }
Subroutine truncate: called CC=1 SCAR=0.0
Pod documented
432  
433 0 ▶sub ungetc { return( shift->_filehandle_method( 'ungetc', @_ ) ); }
Subroutine ungetc: not called CC=1 SCAR=6.9
Pod documented
434  
435 0 ▶sub untaint { return( shift->_filehandle_method( 'untaint', @_ ) ); }
Subroutine untaint: not called CC=1 SCAR=6.9
Pod documented
436  
437 sub wraphandle
438 0 ▶{
Subroutine wraphandle: not called CC=5 SCAR=34.0
Pod documented
439 0 my( $this, $mode ) = @_;
440 0 my $fileno;
441 0 ▶ if( Scalar::Util::blessed( $this ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($this) and $this->can('fileno')) { } 0 0 0
Condition0%0/3
builtin::blessed($this) and $this->can("fileno")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($this) and $this->can("fileno")
builtin::blessed($this) $this->can("fileno")
Truth table0%0/3
A and B
A= builtin::blessed($this)B= $this->can("fileno")
ABresult
0X0
100
111
442 $this->can( 'fileno' ) )
443 {
444 0 $fileno = $this->fileno;
445 }
446 else
447 {
448 0 $fileno = CORE::fileno( $this );
449 }
450  
451 0 ▶ if( !defined( $fileno ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fileno) 0 0 0
452 {
453 0 warn( "Cannot get a file descriptor from the filehandle (${this}) provided.\n" );
454 0 return;
455 }
456 my $io = Module::Generic::File::IO->new( { 'fileno' => $fileno } ) || do
457 0 ▶ {
Condition0%0/3
'Module::Generic::File::IO'->new({'fileno', $fileno}) || do { warn 'Module::Generic::File::IO'->error; return }
l!l&&r!l&&!r
000
MC/DC0%0/2
'Module::Generic::File::IO'->new({'fileno', $fileno}) || do { warn 'Module::Generic::File::IO'->error; return }
'Module::Generic::File::IO'->new({'fileno', $fileno}) do { warn 'Module::Generic::File::IO'->error; return }
Truth table0%0/3
A || B
A= 'Module::Generic::File::IO'->new({'fileno', $fileno})B= do { warn 'Module::Generic::File::IO'->error; return }
ABresult
1X1
011
000
458 0 warn( Module::Generic::File::IO->error );
459 0 return;
460 };
461 0 return( $io );
462 }
463  
464 0 ▶sub write { return( shift->_filehandle_method( 'write', @_ ) ); }
Subroutine write: not called CC=1 SCAR=6.9
Pod documented
465  
466 sub _filehandle_method
467 2838 ▶{
Subroutine _filehandle_method: called CC=13 SCAR=25.7
468 2838 my $self = shift( @_ );
469 # e.g. print, printf, seek, tell, rewinddir, close, etc
470 2838 my $what = shift( @_ );
471 2838 my @rv = ();
472 2838 ▶ my $ref = IO::File->can( $what ) ||
Condition50%1/2
'IO::File'->can($what) || (return $self->error("Method '${what}' is unsupported."))
l!l
28380
MC/DC0%0/1
'IO::File'->can($what) || (return $self->error("Method '${what}' is unsupported."))
'IO::File'->can($what)
Truth table50%1/2
A
A= 'IO::File'->can($what)
Aresult
11
00
473 return( $self->error( "Method '$what' is unsupported." ) );
474 # Check if it is opened.
475 # return( $self->error( "Calling ${what} on a closed filehandle." ) );
476 # return if( !defined( CORE::fileno( $self ) ) );
477 # if( !defined( CORE::fileno( $self ) ) )
478 # {
479 # warn( "Calling ${what} on a closed filehandle: ", $self->_get_stack_trace );
480 # return;
481 # }
482 14 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
483 2838 ▶ if( wantarray() )
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 15 2823 2838
484 {
485 15 local $@;
486 eval
487 15 {
488 15 @rv = $self->$ref( @_ );
489 };
490 15 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 14 15
491 {
492 1 return( $self->error( "An unexpected error occurred while trying to call ${what} in list context: $@" ) );
493 }
494 }
495 else
496 {
497 2823 local $@;
498 eval
499 2823 {
500 2823 $rv[0] = $self->$ref( @_ );
501 };
502 2823 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 3 2820 2823
503 {
504 3 return( $self->error( "An unexpected error occurred while trying to call ${what}: $@" ) );
505 }
506 }
507  
508 2834 ▶ return( $self->error({ skip_frames => 1, message => "Error with $what: $!" }) ) if( CORE::length( $! ) && ( !scalar( @rv ) || !CORE::defined( $rv[0] ) ) );
Branch: 1 branch
BranchTrueFalseTotal
if length $! and not scalar @rv && defined $rv[0] 2 2832 2834
Condition83%5/6
length $! and not scalar @rv && defined $rv[0]
!ll&&!rl&&r
49523372
scalar @rv && defined $rv[0]
!ll&&!rl&&r
022337
MC/DC66%2/3
length $! and not scalar @rv && defined $rv[0]
length $! scalar @rv defined $rv[0]
Truth table75%3/4
A and not(B && C)
A= length $!B= scalar @rvC= defined $rv[0]
ABCresult
0XX0
1110
10X1
1101
509 2832 $self->clear_error;
510 2832 ▶ return if( ( wantarray() && !scalar( @rv ) ) || ( !wantarray() && !defined( $rv[0] ) ) );
Branch: 1 branch
BranchTrueFalseTotal
if wantarray and not scalar @rv or not wantarray || defined $rv[0] 21 2811 2832
Condition100%9/9
wantarray and not scalar @rv or not wantarray || defined $rv[0]
l!l&&r!l&&!r
1202811
wantarray and not scalar @rv
!ll&&!rl&&r
2818131
wantarray || defined $rv[0]
l!l&&r!l&&!r
13279820
MC/DC100%4/4
wantarray and not scalar @rv or not wantarray || defined $rv[0]
wantarray not scalar @rv wantarray defined $rv[0]
Truth table57%4/7
A and not(B) or not(C || D)
A= wantarrayB= not scalar @rvC= wantarrayD= defined $rv[0]
ABCDresult
11XX1
0X001
10001
0X1X0
0X010
101X0
10010
511 2811 ▶ return( wantarray() ? @rv : $rv[0] );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 13 2798 2811
512 }
513  
514 # NOTE: DESTROY
515 sub DESTROY
516 35 ▶{
Subroutine DESTROY: called CC=7 SCAR=19.6
517 # <https://perldoc.perl.org/perlobj#Destructors>
518 35 CORE::local( $., $@, $!, $^E, $? );
519 35 ▶ CORE::return if( Module::Generic::_in_global_destruction() );
Branch: 1 branch
BranchTrueFalseTotal
if Module::Generic::_in_global_destruction() 0 35 35
520 35 my $self = CORE::shift( @_ );
521 35 ▶ CORE::return if( !CORE::defined( $self ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self 0 35 35
522  
523 35 ▶ if( ( Scalar::Util::reftype( $self ) // '' ) eq 'GLOB' )
Branch: 1 branch
BranchTrueFalseTotal
if ((builtin::reftype($self) // "") eq "GLOB") 33 2 35
Condition50%1/2
builtin::reftype($self) // ""
l!l
350
MC/DC0%0/1
builtin::reftype($self) // ""
builtin::reftype($self)
Truth table50%1/2
A
A= builtin::reftype($self)
Aresult
11
00
524 {
525 33 my $fd = $self->fileno;
526 33 ▶ if( $fd )
Branch: 1 branch
BranchTrueFalseTotal
if ($fd) 15 18 33
527 {
528 15 my $repo_key = $fd;
529 15 my $repo = Module::Generic::Global->new( 'fd_locks' => CORE::ref( $self ), key => $repo_key );
530 15 $repo->cleanup;
531 }
532 # NOTE: Storable creates a dummy object as a SCALAR instead of GLOB, so we need to check.
533 33 ▶ $self->close if( $self->opened );
Branch: 1 branch
BranchTrueFalseTotal
if $self->opened 15 18 33
534 }
535 }
536  
537 sub FREEZE
538 1 ▶{
Subroutine FREEZE: called CC=5 SCAR=17.6
Pod undocumented
539 1 my $self = CORE::shift( @_ );
540 1 ▶ my $serialiser = CORE::shift( @_ ) // '';
Condition50%1/2
shift @_ // ""
l!l
10
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
541 1 ▶ my $class = CORE::ref( $self ) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
100
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
542 1 my $args = $self->args;
543 # On or before Sereal version 4.023, Sereal did not support multiple values returned
544 1 ▶ if( $serialiser eq 'Sereal' )
Branch: 1 branch
BranchTrueFalseTotal
if ($serialiser eq "Sereal") 1 0 1
545 {
546 1 require Sereal::Encoder;
547 1 require version;
548
549 1 ▶ if( version->parse( Sereal::Encoder->VERSION ) <= version->parse( '4.023' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ("version"->parse("Sereal::Encoder"->VERSION) <= "version"->parse("4.023")) 0 1 1
550 {
551 0 CORE::return( [$class, \@$args] );
552 }
553 }
554 1 CORE::return( $class, \@$args )
555 }
556  
557 # NOTE: There cannot be a STORABLE_freeze subroutine, or else Storable would trigger an error "Unexpected object type (8) in store_hook()". So Storable must do it by itself, which means it will die or if $Storable::forgive_me is set to a true value, it will instead create a SCALAR instance of this class containing a string like "You lost GLOB(0x5616db45e4e8)"
558 # sub STORABLE_freeze { return( shift->FREEZE( @_ ) ); }
559 #
560 # sub STORABLE_thaw { return( shift->THAW( @_ ) ); }
561  
562 # NOTE: STORABLE_freeze_pre_processing called by Storable::Improved
563 sub STORABLE_freeze_pre_processing
564 1 ▶{
Subroutine STORABLE_freeze_pre_processing: called CC=2 SCAR=7.2
Pod undocumented
565 1 my $self = CORE::shift( @_ );
566 1 ▶ my $class = CORE::ref( $self ) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
100
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
567 1 my $args = $self->args;
568 # We change the glob object into a regular hash-based one to be Storable-friendly
569 1 my $this = CORE::bless( { args => $args, class => $class } => $class );
570 1 CORE::return( $this );
571 }
572  
573 sub STORABLE_thaw_post_processing
574 1 ▶{
Subroutine STORABLE_thaw_post_processing: called CC=8 SCAR=28.4
Pod undocumented
575 1 my $self = CORE::shift( @_ );
576 my $args = ( CORE::exists( $self->{args} ) && CORE::ref( $self->{args} ) eq 'ARRAY' )
577 ? $self->{args}
578 1 ▶ : [];
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'args'} && ref $self->{'args'} eq 'ARRAY' ? : 1 0 1
Condition33%1/3
exists $self->{"args"} and ref $self->{"args"} eq "ARRAY"
!ll&&!rl&&r
001
MC/DC0%0/2
exists $self->{"args"} and ref $self->{"args"} eq "ARRAY"
exists $self->{"args"} ref $self->{"args"} eq "ARRAY"
Truth table33%1/3
A and B
A= exists $self->{"args"}B= ref $self->{"args"} eq "ARRAY"
ABresult
0X0
100
111
579 my $class = ( CORE::exists( $self->{class} ) && CORE::defined( $self->{class} ) && CORE::length( $self->{class} ) )
580 ? $self->{class}
581 1 ▶ : ( CORE::ref( $self ) || $self );
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'class'} && defined $self->{'class'} && length $self->{'class'} ? : 1 0 1
Condition22%2/9
exists $self->{"class"} and defined $self->{"class"} and length $self->{"class"}
!ll&&!rl&&r
001
exists $self->{"class"} and defined $self->{"class"}
!ll&&!rl&&r
001
ref $self or $self
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $self->{"class"} and defined $self->{"class"} and length $self->{"class"}
exists $self->{"class"} defined $self->{"class"} length $self->{"class"}
MC/DC0%0/2
ref $self or $self
ref $self $self
Truth table25%1/4
A and B and C
A= exists $self->{"class"}B= defined $self->{"class"}C= length $self->{"class"}
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/3
A or B
A= ref $selfB= $self
ABresult
1X1
011
000
582 # We restore our glob object. Geez that was hard. Not.
583 1 ▶ my $obj = $THAW_REOPENS_FILE ? $class->new( @$args ) : $class->new;
Branch: 1 branch
BranchTrueFalseTotal
$Module::Generic::File::IO::THAW_REOPENS_FILE ? : 1 0 1
584 1 return( $obj );
585 }
586  
587 # NOTE: THAW is called by Sereal and CBOR
588 sub THAW
589 1 ▶{
Subroutine THAW: called CC=12 SCAR=35.0
Pod undocumented
590 1 my( $self, undef, @args ) = @_;
591 1 ▶ my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args;
Branch: 1 branch
BranchTrueFalseTotal
scalar @args == 1 && ref $args[0] eq 'ARRAY' ? : 0 1 1
Condition33%1/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
!ll&&!rl&&r
100
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1 ref $args[0] eq "ARRAY"
Truth table33%1/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
ABresult
0X0
100
111
592 1 ▶ my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self );
Branch: 1 branch
BranchTrueFalseTotal
defined $ref && ref $ref eq 'ARRAY' && scalar @$ref > 1 ? : 1 0 1
Condition22%2/9
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
!ll&&!rl&&r
001
defined $ref and ref $ref eq "ARRAY"
!ll&&!rl&&r
001
ref $self or $self
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref ref $ref eq "ARRAY" scalar @$ref > 1
MC/DC0%0/2
ref $self or $self
ref $self $self
Truth table25%1/4
A and B and C
A= defined $refB= ref $ref eq "ARRAY"C= scalar @$ref > 1
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/3
A or B
A= ref $selfB= $self
ABresult
1X1
011
000
593 1 ▶ $ref = ( CORE::scalar( @$ref ) && CORE::ref( $ref->[0] ) eq 'ARRAY' ) ? $ref->[0] : [];
Branch: 1 branch
BranchTrueFalseTotal
scalar @$ref && ref $ref->[0] eq 'ARRAY' ? : 1 0 1
Condition33%1/3
scalar @$ref and ref $ref->[0] eq "ARRAY"
!ll&&!rl&&r
001
MC/DC0%0/2
scalar @$ref and ref $ref->[0] eq "ARRAY"
scalar @$ref ref $ref->[0] eq "ARRAY"
Truth table33%1/3
A and B
A= scalar @$refB= ref $ref->[0] eq "ARRAY"
ABresult
0X0
100
111
594 1 my $new;
595 1 ▶ if( $THAW_REOPENS_FILE && CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' )
Branch: 1 branch
BranchTrueFalseTotal
if ($Module::Generic::File::IO::THAW_REOPENS_FILE and defined $ref and ref $ref eq 'ARRAY') { } 1 0 1
Condition33%2/6
$Module::Generic::File::IO::THAW_REOPENS_FILE and defined $ref and ref $ref eq "ARRAY"
!ll&&!rl&&r
001
$Module::Generic::File::IO::THAW_REOPENS_FILE and defined $ref
!ll&&!rl&&r
001
MC/DC0%0/3
$Module::Generic::File::IO::THAW_REOPENS_FILE and defined $ref and ref $ref eq "ARRAY"
$Module::Generic::File::IO::THAW_REOPENS_FILE defined $ref ref $ref eq "ARRAY"
Truth table25%1/4
A and B and C
A= $Module::Generic::File::IO::THAW_REOPENS_FILEB= defined $refC= ref $ref eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
596 {
597 1 $new = $class->new( @$ref );
598 }
599 else
600 {
601 0 $new = $class->new;
602 }
603 1 CORE::return( $new );
604 }
605  
606 14 1;
607 # NOTE: POD
608 __END__
« lib/Module/Generic/Iterator.pm ↑ Summary lib/Module/Generic/Hash.pm »