Branch Coverage

blib/lib/File/Replace.pm
Criterion Covered Total %
branch 142 158 91.1


line true false branch
22 5 0 if ($] ge '5.010' or defined &Hash::Util::lock_ref_keys) { }
39 0 1 if $_[$i] =~ /^-i|^-D$/
40 0 5 if (@mine and my(@i) = grep({/^-i/;} @mine))
41 0 0 if @i > 1
44 0 0 unless my($ext) = $i[0] =~ /^-i(.*)$/
63 1 78 unless @_
66 6 72 @_ % 2 ? :
69 22 47 unless $NEW_KNOWN_OPTS{$_}
71 1 3 if $opts{'autocancel'} and $opts{'autofinish'}
72 1 54 unless (defined wantarray)
73 9 45 if (defined $opts{'create'}) { }
74 3 6 if ($opts{'create'} eq 'off' or $opts{'create'} eq 'no') { }
3 3 elsif ($opts{'create'} eq 'now' or $opts{'create'} eq 'later') { }
83 1 50 if $self->{'debug'} and not ref $self->{'debug'}
84 6 45 if (defined $_layers)
85 1 5 if exists $self->{'layers'}
90 4 46 if defined $self->{'perms'}
95 5 45 if defined $self->{'layers'}
98 5 45 defined $self->{'layers'} ? :
99 5 45 if (defined $self->{'in_fh'}) { }
25 20 elsif (not open($self->{'ifh'}, $openmode, $filename)) { }
100 1 4 unless defined fileno $self->{'in_fh'}
105 23 2 if ($!{'ENOENT'} and $self->{'create'} eq 'now' || $self->{'create'} eq 'later') { }
106 1 1 defined $self->{'layers'} ? :
2 21 if $self->{'create'} eq "now"
109 2 21 $self->{'create'} eq 'now' ? :
23 0 if (open $self->{'ifh'}, $openmode, $self->{'create'} eq 'now' ? $filename : &devnull()) { }
110 22 1 unless defined $self->{'setperms'}
114 2 47 if (not defined $self->{'ifh'}) { }
121 21 26 unless (defined $self->{'setperms'})
122 19 2 if ($self->{'chmod'}) { }
126 1 18 unless my(undef, undef, $mode) = stat $self->{'ifh'}
135 4 42 if (defined $self->{'backup'} and length $self->{'backup'})
137 1 3 if ($self->{'backup'} =~ /\*/)
141 1 3 if -e $bakfile
143 1 2 unless File::Copy::syscopy($filename, $bakfile)
151 5 39 defined $self->{'layers'} ? :
157 1 3 unless (defined wantarray)
165 0 0 unless (defined wantarray)
168 0 0 if (wantarray) { }
180 0 0 unless (defined wantarray)
195 10 17 if exists $self->{$o}
196 1 2 wantarray ? :
203 1 22 unless $self->{'is_open'}
204 14 8 @_ % 2 ? :
206 14 8 if (defined $_count)
207 1 13 if exists $opts{'count'}
210 1 31 unless $COPY_KNOWN_OPTS{$_}
211 15 5 unless defined $opts{'bufsize'}
212 2 18 unless $opts{'count'} and $opts{'count'} =~ /\A\d+\z/
213 2 16 unless $opts{'bufsize'} and $opts{'bufsize'} =~ /\A\d+\z/
215 1 15 if defined $opts{'less'} and not $opts{'less'} =~ /\A(?:ok|ignore)\z/
219 6 9 $remain > $opts{'bufsize'} ? :
220 1 14 unless defined $in
221 1 13 unless print {$self->{'ofh'};} $buf
225 3 10 if $remain and not $opts{'less'}
231 1 31 if @_
232 1 31 unless ($self->{'is_open'})
240 1 30 if (defined fileno $ifh and not close $ifh) { }
1 29 elsif (defined fileno $ofh and not close $ofh) { }
0 29 elsif ($self->{'chmod'} and not chmod($self->{'setperms'}, $ofn)) { }
0 29 elsif (not rename($ofn, $ifn)) { }
248 2 29 if (defined $fail)
260 51 13 if ($from eq 'destroy') { }
11 2 elsif ($from eq 'cancel') { }
262 2 49 if $self->{'is_open'}
264 2 9 unless $self->{'is_open'}
265 15 49 unless ($from eq "destroy" and not $self->{'is_open'})
268 13 2 defined $self->{'ifn'} ? :
13 2 defined $self->{'ofn'} ? :
272 2 14 unless defined $ifh and defined fileno $ifh and close $ifh
273 1 16 unless defined $ofh and defined fileno $ofh and close $ofh
274 17 47 if defined $ofn
275 13 51 if ($success) { }
282 7 44 if ($self->{'is_open'})
283 3 4 if ($self->{'autocancel'}) { }
2 2 elsif ($self->{'autofinish'}) { }
292 79 10 unless $self->{'debug'}
293 1 9 unless @_