blib/lib/Acme/InputRecordSeparatorIsRegexp.pm

filter: Statementstmt 74.1% 218 / 294 Branchbran 62.2% 71 / 114 Conditioncond 50.9% 27 / 53 MC/DCmcdc 33.3% 11 / 33 Subroutinesub 87.8% 29 / 33 Podpod 80.0% 4 / 5 totaltotal 67.6% 360 / 532 SCAR 56.3
CC
80
Cov
69%
READ
72.0
open
30.0
EOF
12.0
CRAP 279.2
↑ Summary
1 package Acme::InputRecordSeparatorIsRegexp;
2  
3 12 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 require Exporter;
10 12 our @ISA = 'Exporter';
11 12 our @EXPORT_OK = ('open','autochomp','input_record_separator');
12 12 our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
13  
14 BEGIN {
15 12 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶ *{ 'Acme::IRSRegexp' . "::" } = \*{ __PACKAGE__ . "::" };
Subroutine BEGIN: called CC=1 SCAR=0.0
17 }
18  
19 12 our $VERSION = '0.06';
20  
21 sub TIEHANDLE {
22 16 ▶ my ($pkg, @opts) = @_;
Subroutine TIEHANDLE: called CC=5 SCAR=16.5
23 16 my $handle;
24 16 ▶ if (@opts % 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@opts % 2) { } 2 14 16
25 2 $handle = Symbol::gensym;
26 } else {
27 14 my $fh = *{shift @opts};
28 # will fail if open for $fh failed, but that's not important
29 14 eval { CORE::open $handle, '<&+', $fh };
30 }
31 16 my $rs = shift @opts;
32 16 my %opts = @opts;
33 16 ▶ $opts{maxrecsize} ||= ($opts{bufsize} || 16384) / 4;
Condition40%2/5
$opts{"maxrecsize"} ||= ($opts{"bufsize"} || 16384) / 4
l!l&&r!l&&!r
0160
$opts{'bufsize'} || 16384
l!l
016
MC/DC0%0/2
$opts{"maxrecsize"} ||= ($opts{"bufsize"} || 16384) / 4
$opts{"maxrecsize"} $opts{'bufsize'}
Truth table0%0/3
A ||= B
A= $opts{"maxrecsize"}B= $opts{'bufsize'}
ABresult
1X1
011
000
34 16 ▶ $opts{bufsize} ||= $opts{maxrecsize} * 4;
Condition33%1/3
$opts{"bufsize"} ||= $opts{"maxrecsize"} * 4
l!l&&r!l&&!r
0160
MC/DC0%0/2
$opts{"bufsize"} ||= $opts{"maxrecsize"} * 4
$opts{"bufsize"} $opts{"maxrecsize"} * 4
Truth table33%1/3
A ||= B
A= $opts{"bufsize"}B= $opts{"maxrecsize"} * 4
ABresult
1X1
011
000
35 16 my $self = bless {
36 %opts,
37 handle => $handle,
38 rs => $rs,
39 records => [],
40 buffer => ''
41 }, $pkg;
42 16 $self->_compile_rs;
43 16 return $self;
44 }
45  
46 sub open (*;$@) {
47 12 ▶ no strict 'refs'; # or else bareword file handles will break
Subroutine BEGIN: called CC=1 SCAR=0.0
48 17 ▶ my (undef,$mode,$expr,@list) = @_;
Subroutine open: called CC=18 SCAR=34.0
Pod documented
49 17 ▶ if (!defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[0]) 17 0 17
50 17 $_[0] = Symbol::gensym;
51 }
52 17 my $glob = $_[0];
53 17 ▶ if (!ref($glob) && $glob !~ /::/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $glob or $glob =~ /::/) 0 17 17
Condition33%1/3
ref $glob or $glob =~ /::/
l!l&&r!l&&!r
1700
MC/DC0%0/2
ref $glob or $glob =~ /::/
ref $glob $glob =~ /::/
Truth table33%1/3
A or B
A= ref $globB= $glob =~ /::/
ABresult
1X1
011
000
54 0 ▶ $glob = join("::",caller(0) || "", $glob);
Condition0%0/2
caller 0 || ''
l!l
00
MC/DC0%0/1
caller 0 || ''
caller 0
Truth table0%0/2
A
A= caller 0
Aresult
11
00
55 0 print STDERR "new glob is $glob\n";
56 }
57  
58 17 ▶ if ($mode && index($mode,":irs(") >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode and index($mode, ":irs(") != -1) 7 10 17
Condition66%2/3
$mode and index($mode, ":irs(") != -1
!ll&&!rl&&r
0107
MC/DC50%1/2
$mode and index($mode, ":irs(") != -1
$mode index($mode, ":irs(") != -1
Truth table66%2/3
A and B
A= $modeB= index($mode, ":irs(") != -1
ABresult
0X0
100
111
59 7 my $irs = "";
60 7 my $p0 = index($mode,":irs(");
61 7 my $p1 = $p0 + 5;
62 7 my $nest = 1;
63 7 ▶ while ($nest) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nest) 63 7 70
64 63 my $c = eval { substr($mode,$p1++,1) };
65 63 ▶ if ($@ || !defined($c)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not defined $c) 0 63 63
Condition33%1/3
$@ or not defined $c
l!l&&r!l&&!r
0063
MC/DC0%0/2
$@ or not defined $c
$@ not defined $c
Truth table33%1/3
A or not(B)
A= $@B= not defined $c
ABresult
1X1
011
000
66 0 carp "Argument list not closed for PerlIO layer \"$irs\"";
67 0 return;
68 }
69 63 ▶ if ($c eq "\\") {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "\\") 16 47 63
70 16 $c .= substr($mode,$p1++,1);
71 }
72 63 ▶ if ($c eq "(") { $nest++ }
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "(") 0 63 63
73 63 ▶ if ($c eq ")") { $nest-- }
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq ")") 7 56 63
74 63 ▶ if ($nest) { $irs .= $c; }
Branch: 1 branch
BranchTrueFalseTotal
if ($nest) 56 7 63
75 }
76 7 substr($mode,$p0,length($irs)+6, "");
77 7 ▶ my $z = @list ? CORE::open *$glob, $mode, $expr, @list
Branch: 1 branch
BranchTrueFalseTotal
@list ? : 0 7 7
78 : CORE::open *$glob, $mode, $expr;
79 7 tie *$glob, __PACKAGE__, *$glob, $irs;
80 7 return $z;
81 }
82 10 ▶ if (@list) {
Branch: 3 branches
BranchTrueFalseTotal
if (@list) { } 0 10 10
elsif ($expr) { } 10 0 10
elsif ($mode) { } 0 0 0
83 0 return CORE::open(*$glob,$mode,$expr,@list);
84 } elsif ($expr) {
85 10 return CORE::open(*$glob,$mode,$expr);
86 } elsif ($mode) {
87 0 return CORE::open(*$glob,$mode);
88 } else {
89 0 return CORE::open(*$glob);
90 }
91 }
92  
93 sub _compile_rs {
94 40 ▶ my $self = shift;
Subroutine _compile_rs: called CC=4 SCAR=16.6
95 40 my $rs = $self->{rs};
96  
97 40 my $q = eval { my @q = split /(?<=${rs})/,""; 1 };
98 40 ▶ if ($q) {
Branch: 1 branch
BranchTrueFalseTotal
if ($q) { } 40 0 40
99 40 $self->{rsc} = qr/(?<=${rs})/s;
100 40 ▶ if ($rs =~ /\?\^\w*m/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rs =~ /\?\^\w*m/) 0 40 40
101 0 $self->{rsc} = qr/(?<=${rs})/ms;
102 }
103 40 $self->{can_use_lookbehind} = 1;
104 } else {
105 0 $self->{rsc} = qr/(.*?(?:${rs}))/s;
106 0 ▶ if ($rs =~ /\?\^\w*m/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rs =~ /\?\^\w*m/) 0 0 0
107 0 $self->{rsc} = qr/(.*?(?:${rs}))/ms;
108 }
109 0 $self->{can_use_lookbehind} = 0;
110 }
111 40 return;
112 }
113  
114 sub READLINE {
115 5812 ▶ my $self = shift;
Subroutine READLINE: called CC=7 SCAR=19.6
116 5812 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 3 5809 5812
117 3 local $/ = undef;
118 3 $self->{buffer} .= readline($self->{handle});
119 3 push @{$self->{records}}, $self->_split;
120 3 $self->{buffer} = "";
121 3 my @rec = splice @{$self->{records}};
122 3 ▶ if (@rec && $self->{autochomp}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rec and $self->{"autochomp"}) 0 3 3
Condition33%1/3
@rec and $self->{"autochomp"}
!ll&&!rl&&r
030
MC/DC0%0/2
@rec and $self->{"autochomp"}
@rec $self->{"autochomp"}
Truth table33%1/3
A and B
A= @recB= $self->{"autochomp"}
ABresult
0X0
100
111
123 0 $self->chomp( @rec );
124 }
125 3 return @rec;
126 }
127 # want scalar
128 5809 ▶ if (!@{$self->{records}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$self->{"records"};}) 2921 2888 5809
129 2921 $self->_populate_buffer;
130 }
131 5809 my $rec = shift @{$self->{records}};
132 5809 ▶ if (defined($rec) && $self->{autochomp}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rec and $self->{"autochomp"}) 61 5748 5809
Condition100%3/3
defined $rec and $self->{"autochomp"}
!ll&&!rl&&r
10573861
MC/DC100%2/2
defined $rec and $self->{"autochomp"}
defined $rec $self->{"autochomp"}
Truth table100%3/3
A and B
A= defined $recB= $self->{"autochomp"}
ABresult
0X0
100
111
133 61 $self->chomp( $rec );
134 }
135 5809 return $rec;
136 }
137  
138 sub _populate_buffer {
139 2922 ▶ my $self = shift;
Subroutine _populate_buffer: called CC=7 SCAR=19.5
140 2922 my $handle = $self->{handle};
141 2922 ▶ return if !$handle || eof($handle);
Branch: 1 branch
BranchTrueFalseTotal
if not $handle or eof $handle 10 2912 2922
Condition66%2/3
not $handle or eof $handle
l!l&&r!l&&!r
0102912
MC/DC50%1/2
not $handle or eof $handle
not $handle eof $handle
Truth table66%2/3
not(A) or B
A= not $handleB= eof $handle
ABresult
1X1
011
000
142
143 # my $rs = $self->{rsc} || $self->{rs};
144 2912 my @rec;
145 {
146 2912 my $buffer = '';
147 2914 my $n = read $handle, $buffer, $self->{bufsize};
148 2914 $self->{buffer} .= $buffer;
149 2914 @rec = $self->_split;
150 2914 ▶ redo if !eof($handle) && @rec == 1;
Branch: 1 branch
BranchTrueFalseTotal
if not eof $handle and @rec == 1 2 2912 2914
Condition100%3/3
not eof $handle and @rec == 1
!ll&&!rl&&r
48124312
MC/DC100%2/2
not eof $handle and @rec == 1
not eof $handle @rec == 1
Truth table100%3/3
not(A) and B
A= not eof $handleB= @rec == 1
ABresult
0X0
100
111
151 }
152 2912 push @{$self->{records}}, @rec;
153 2912 $self->{buffer} = '';
154 2912 ▶ if (eof($handle)) {
Branch: 1 branch
BranchTrueFalseTotal
if (eof $handle) 481 2431 2912
155 481 return;
156 }
157  
158 2431 ▶ if (@{$self->{records}} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"records"};} > 1) 2431 0 2431
159 2431 $self->{buffer} = pop @{$self->{records}};
160 }
161 2431 return;
162 }
163  
164 sub EOF {
165 0 ▶ my $self = shift;
Subroutine EOF: not called CC=3 SCAR=24.8
166 0 foreach my $rec (@{$self->{records}}, $self->{buffer}) {
167 0 ▶ return if length($rec) > 0;
Branch: 1 branch
BranchTrueFalseTotal
if length $rec > 0 0 0 0
168 }
169 0 return eof($self->{handle});
170 }
171  
172 sub _split {
173 2917 ▶ my $self = shift;
Subroutine _split: called CC=3 SCAR=12.0
174 2917 ▶ if (!defined $self->{can_use_lookbehind}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"can_use_lookbehind"}) 0 2917 2917
175 0 $self->_compile_rs;
176 }
177 2917 my $rs = $self->{rsc};
178 2917 my @rec = split $rs, $self->{buffer};
179 2917 ▶ if ($self->{can_use_lookbehind}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'can_use_lookbehind'}) { } 2917 0 2917
180 2917 return @rec;
181 } else {
182 0 return grep length, @rec;
183 }
184 }
185  
186 sub CLOSE {
187 8 ▶ my $self = shift;
Subroutine CLOSE: called CC=1 SCAR=0.0
188 8 $self->_clear_buffer;
189 8 my $z = close $self->{handle};
190 # delete $self->{handle};
191 8 return $z;
192 }
193  
194 sub _clear_buffer {
195 2850 ▶ my $self = shift;
Subroutine _clear_buffer: called CC=1 SCAR=0.0
196 2850 $self->{buffer} = '';
197 2850 $self->{records} = [];
198 }
199  
200 sub OPEN {
201 3 ▶ my ($self, $mode, @args) = @_;
Subroutine OPEN: called CC=3 SCAR=11.2
202 3 ▶ if ($self->{handle}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"handle"}) 3 0 3
203 # close $self->{handle};
204 }
205 3 my $z = CORE::open $self->{handle}, $mode, @args;
206 3 ▶ if ($z) {
Branch: 1 branch
BranchTrueFalseTotal
if ($z) 3 0 3
207 3 $self->_clear_buffer;
208 }
209 3 return $z;
210 }
211  
212 sub FILENO {
213 1 ▶ my $self = shift;
Subroutine FILENO: called CC=1 SCAR=0.0
214 1 return fileno($self->{handle});
215 }
216  
217 sub WRITE {
218 0 ▶ my ($self, $buf, $len, $offset) = @_;
Subroutine WRITE: not called CC=3 SCAR=24.8
219 0 ▶ $offset ||= 0;
Condition0%0/2
$offset ||= 0
l!l
00
MC/DC0%0/1
$offset ||= 0
$offset
Truth table0%0/2
A
A= $offset
Aresult
11
00
220 0 ▶ if (!defined $len) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $len) 0 0 0
221 0 $len = length($buf)-$offset;
222 }
223 0 $self->PRINT( substr($buf,$offset,$len) );
224 }
225  
226 sub PRINT {
227 13 ▶ my ($self, @msg) = @_;
Subroutine PRINT: called CC=2 SCAR=6.9
228 13 ▶ if ($self->TELL() != tell($self->{handle})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->TELL != tell $self->{'handle'}) { } 1 12 13
229 1 $self->SEEK(0,1);
230 } else {
231 12 $self->_clear_buffer;
232 }
233 13 print {$self->{handle}} @msg;
234 }
235  
236 sub PRINTF {
237 0 ▶ my ($self, $template, @args) = @_;
Subroutine PRINTF: not called CC=1 SCAR=6.9
238 0 $self->PRINT(sprintf($template,@args));
239 }
240  
241 sub READ {
242 0 ▶ my $self = shift;
Subroutine READ: not called CC=8 SCAR=42.8
243 0 my $bufref = \$_[0];
244 0 my (undef, $len, $offset) = @_;
245 0 my $nread = 0;
246  
247 0 ▶ while ($len > 0 && @{$self->{records}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len > 0 and @{$self->{"records"};}) 0 0 0
Condition0%0/3
$len > 0 and @{$self->{"records"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$len > 0 and @{$self->{"records"};}
$len > 0 @{$self->{"records"};}
Truth table0%0/3
A and B
A= $len > 0B= @{$self->{"records"};}
ABresult
0X0
100
111
248 0 ▶ if (length($self->{records}[0])>=$len) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{'records'}[0] >= $len) { } 0 0 0
249 0 my $rec = shift @{$self->{records}};
250 0 my $reclen = length($rec);
251 0 substr( $$bufref, $offset, $reclen, $rec);
252 0 $len -= $reclen;
253 0 $offset += $reclen;
254 0 $nread += $reclen;
255 } else {
256 0 my $rec = substr($self->{records}[0], 0, $len, "");
257 0 substr( $$bufref, $offset, $len, $rec);
258 0 $offset += $len;
259 0 $nread += $len;
260 0 $len = 0;
261 }
262 }
263 0 ▶ if ($len > 0 && length($self->{buffer}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len > 0 and length $self->{"buffer"} > 0) 0 0 0
Condition0%0/3
$len > 0 and length $self->{"buffer"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$len > 0 and length $self->{"buffer"} > 0
$len > 0 length $self->{"buffer"} > 0
Truth table0%0/3
A and B
A= $len > 0B= length $self->{"buffer"} > 0
ABresult
0X0
100
111
264 0 my $reclen = length($self->{buffer});
265 0 ▶ if ($reclen >= $len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reclen >= $len) { } 0 0 0
266 0 my $rec = substr( $self->{buffer}, 0, $len, "" );
267 0 substr( $$bufref, $offset, $len, $rec );
268 0 $offset += $len;
269 0 $nread += $len;
270 0 $len = 0;
271 } else {
272 0 substr( $$bufref, $offset, $reclen, $self->{buffer} );
273 0 $self->{buffer} = "";
274 0 $offset += $reclen;
275 0 $nread += $reclen;
276 0 $len -= $reclen;
277 }
278 }
279 0 ▶ if ($len > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len > 0) { } 0 0 0
280 0 return $nread + read $self->{handle}, $$bufref, $len, $offset;
281 } else {
282 0 return $nread;
283 }
284 }
285  
286 sub GETC {
287 1 ▶ my $self = shift;
Subroutine GETC: called CC=6 SCAR=23.0
288 1 ▶ if (@{$self->{records}}==0 && 0 == length($self->{buffer})) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"records"};} == 0 and 0 == length $self->{"buffer"}) 1 0 1
Condition33%1/3
@{$self->{"records"};} == 0 and 0 == length $self->{"buffer"}
!ll&&!rl&&r
001
MC/DC0%0/2
@{$self->{"records"};} == 0 and 0 == length $self->{"buffer"}
@{$self->{"records"};} == 0 0 == length $self->{"buffer"}
Truth table33%1/3
A and B
A= @{$self->{"records"};} == 0B= 0 == length $self->{"buffer"}
ABresult
0X0
100
111
289 1 $self->_populate_buffer;
290 }
291  
292 1 ▶ if (@{$self->{records}}) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$self->{'records'};}) { } 1 0 1
elsif (0 != length $self->{'buffer'}) { } 0 0 0
293 1 my $c = substr( $self->{records}[0], 0, 1, "" );
294 1 ▶ if (0 == length($self->{records}[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 == length $self->{"records"}[0]) 0 1 1
295 0 shift @{$self->{records}};
296 }
297 1 return $c;
298 } elsif (0 != length($self->{buffer})) {
299 0 my $c = substr( $self->{buffer}, 0, 1, "" );
300 0 return $c;
301 } else {
302 # eof?
303 0 return undef;
304 }
305 }
306  
307 sub BINMODE {
308 1 ▶ my $self = shift;
Subroutine BINMODE: called CC=2 SCAR=7.4
309 1 my $handle = $self->{handle};
310 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 1 1
311 0 binmode $handle, @_;
312 } else {
313 1 binmode $handle;
314 }
315 }
316  
317 sub SEEK {
318 2827 ▶ my ($self, $pos, $whence) = @_;
Subroutine SEEK: called CC=2 SCAR=6.9
319  
320 2827 ▶ if ($whence == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($whence == 1) 1 2826 2827
321 1 $whence = 0;
322 1 $pos += $self->TELL;
323 }
324  
325 # easy implementation:
326 # on any seek, clear records, buffer
327  
328 2827 $self->_clear_buffer;
329 2827 seek $self->{handle}, $pos, $whence;
330  
331 # more sophisticated implementation
332 # on a seek forward, remove bytes from the front
333 # of buffered data
334 }
335  
336 sub TELL {
337 2854 ▶ my $self = shift;
Subroutine TELL: called CC=2 SCAR=6.9
338 # virtual cursor position is actual position on the file handle
339 # minus the length of any buffered data
340 2854 my $tell = tell $self->{handle};
341 2854 $tell -= length($self->{buffer});
342 2854 $tell -= length($_) for @{$self->{records}};
343 2854 return $tell;
344 }
345  
346  
347 12 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
348 sub IO::Handle::input_record_separator {
349 8 ▶ my $self = shift;
Subroutine input_record_separator: called CC=7 SCAR=23.5
Pod undocumented
350 8 ▶ if (ref($self) eq 'GLOB' || ref(\$self) eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self eq 'GLOB' or ref \$self eq 'GLOB') { } 8 0 8
Condition66%2/3
ref $self eq "GLOB" or ref \$self eq "GLOB"
l!l&&r!l&&!r
620
MC/DC0%0/2
ref $self eq "GLOB" or ref \$self eq "GLOB"
ref $self eq "GLOB" ref \$self eq "GLOB"
Truth table66%2/3
A or B
A= ref $self eq "GLOB"B= ref \$self eq "GLOB"
ABresult
1X1
011
000
351 8 ▶ if (tied(*$self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (tied *$self) 3 5 8
352 3 ▶ if (ref(tied(*$self)) eq __PACKAGE__) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref tied *$self eq __PACKAGE__) 3 0 3
353 3 return input_record_separator($self,@_);
354 }
355 0 my $z = eval { (tied *$self)->input_record_separator(@_) };
356 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
357 0 carp "input_record_separator is not supported on tied handle";
358 }
359 0 return $z;
360 }
361 5 ▶ if (!@_) { return $/ }
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 3 2 5
362 2 $self = tie *$self, __PACKAGE__, $self, quotemeta($/);
363 2 return input_record_separator($self,@_);
364 } else {
365 0 carp "input to input_record_separator was not a handle";
366 0 return;
367 }
368 }
369  
370  
371 sub input_record_separator {
372 26 ▶ my $self = shift;
Subroutine input_record_separator: called CC=6 SCAR=17.9
Pod documented
373 26 ▶ if (ref($self) eq 'GLOB' || ref(\$self) eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self eq "GLOB" or ref \$self eq "GLOB") 16 10 26
Condition100%3/3
ref $self eq "GLOB" or ref \$self eq "GLOB"
l!l&&r!l&&!r
10610
MC/DC100%2/2
ref $self eq "GLOB" or ref \$self eq "GLOB"
ref $self eq "GLOB" ref \$self eq "GLOB"
Truth table100%3/3
A or B
A= ref $self eq "GLOB"B= ref \$self eq "GLOB"
ABresult
1X1
011
000
374 16 ▶ if (!tied *$self) {
Branch: 1 branch
BranchTrueFalseTotal
if (not tied *$self) { } 4 12 16
375 4 ▶ if (!@_) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 2 2 4
376 2 return IO::Handle::input_record_separator(*$self);
377 }
378 2 $self = tie *$self, __PACKAGE__, $self, quotemeta($/);
379 } else {
380 12 $self = tied *$self;
381 }
382 }
383 24 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 10 14 24
384 10 $self->{rs} = shift;
385 10 delete $self->{can_use_lookbehind};
386 }
387 24 $self->_compile_rs;
388 24 return $self->{rs};
389 }
390  
391 sub autochomp {
392 14 ▶ my $self = shift;
Subroutine autochomp: called CC=7 SCAR=19.5
Pod documented
393 14 ▶ if (ref($self) eq 'GLOB' || ref(\$self) eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self eq "GLOB" or ref \$self eq "GLOB") 7 7 14
Condition100%3/3
ref $self eq "GLOB" or ref \$self eq "GLOB"
l!l&&r!l&&!r
617
MC/DC100%2/2
ref $self eq "GLOB" or ref \$self eq "GLOB"
ref $self eq "GLOB" ref \$self eq "GLOB"
Truth table100%3/3
A or B
A= ref $self eq "GLOB"B= ref \$self eq "GLOB"
ABresult
1X1
011
000
394 7 ▶ if (!tied *$self) {
Branch: 1 branch
BranchTrueFalseTotal
if (not tied *$self) { } 2 5 7
395 2 ▶ if (!@_) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 1 1 2
396 1 return 0;
397 }
398 1 $self = tie *$self, __PACKAGE__, $self, quotemeta($/);
399 } else {
400 5 $self = tied *$self;
401 }
402 }
403 13 ▶ my $val = $self->{autochomp} || 0;
Condition100%2/2
$self->{'autochomp'} || 0
l!l
58
MC/DC100%1/1
$self->{'autochomp'} || 0
$self->{'autochomp'}
Truth table100%2/2
A
A= $self->{'autochomp'}
Aresult
11
00
404 13 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 5 8 13
405 5 $self->{autochomp} = 0+!!$_[0];
406 }
407 13 return 0+$val;
408 }
409  
410 sub chomp {
411 124 ▶ my $self = shift;
Subroutine chomp: called CC=3 SCAR=11.0
Pod documented
412 124 my $removed = 0;
413 124 my $rs = $self->{rs};
414 124 foreach my $line (@_) {
415 124 $line =~ s/($rs)$//;
416 124 ▶ if (defined($1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $1) 95 29 124
417 95 $removed += length($1);
418 }
419 }
420 124 return $removed;
421 }
422  
423 12 1; #
424  
425 __END__
↑ Summary