| 1 | package App::TimelogTxt::File; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.22'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 14 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=19.0
Pod
documented
| |||||||||||||||||||||||||||||
| 9 | 14 | my ($class, $fh, $start, $end) = @_; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 14 | ▶ | die "Missing required file handle or file name.\n" unless defined $fh; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 12 | 13 | ▶ | die "Missing required start marker.\n" unless defined $start; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | 12 | ▶ | die "Missing required end marker.\n" unless defined $end; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | 11 | ▶ | if( !ref $fh ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | 0 | my $name = $fh; | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | open( $fh, '<', $name ) or die "Unable to open file '$name': $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 11 | my $obj = { | |||||||||||||||||||||||||||
| 20 | fh => $fh, | ||||||||||||||||||||||||||||
| 21 | start => $start, | ||||||||||||||||||||||||||||
| 22 | startlen => length $start, | ||||||||||||||||||||||||||||
| 23 | end => $end, | ||||||||||||||||||||||||||||
| 24 | endlen => length $end, | ||||||||||||||||||||||||||||
| 25 | stage => 0, | ||||||||||||||||||||||||||||
| 26 | }; | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 11 | return bless $obj, $class; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 43 | ▶ | sub readline { | ||||||||||||||||||||||||||
|
Subroutine
readline: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 43 | my ($self) = @_; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 43 | ▶ | return if $self->{'stage'} > 1 or eof( $self->{'fh'} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"stage"} > 1 or eof $self->{"fh"}
MC/DC100%2/2
$self->{"stage"} > 1 or eof $self->{"fh"}
$self->{"stage"} > 1
eof $self->{"fh"}
Truth table100%3/3
A or B
A= $self->{"stage"} > 1B= eof $self->{"fh"}
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 35 | my $line; | |||||||||||||||||||||||||||
| 37 | 35 | ▶ | if( $self->{'stage'} == 0 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||
| 39 | 11 | ▶ | 0 while( defined( $line = readline $self->{'fh'} ) && substr( $line, 0, $self->{'startlen'} ) lt $self->{'start'} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined($line = CORE::readline $self->{"fh"}) and substr($line, 0, $self->{"startlen"}) lt $self->{"start"}
MC/DC100%2/2
defined($line = CORE::readline $self->{"fh"}) and substr($line, 0, $self->{"startlen"}) lt $self->{"start"}
defined($line = CORE::readline $self->{"fh"})
substr($line, 0, $self->{"startlen"}) lt $self->{"start"}
Truth table100%3/3
A and B
A= defined($line = CORE::readline $self->{"fh"})B= substr($line, 0, $self->{"startlen"}) lt $self->{"start"}
| |||||||||||||||||||||||||||||
| 40 | 11 | $self->{'stage'} = 1; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | else | ||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | 24 | $line = readline $self->{'fh'}; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 35 | ▶ | return $line if !defined $line || substr( $line, 0, $self->{'endlen'} ) lt $self->{'end'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $line or substr($line, 0, $self->{"endlen"}) lt $self->{"end"}
MC/DC100%2/2
not defined $line or substr($line, 0, $self->{"endlen"}) lt $self->{"end"}
not defined $line
substr($line, 0, $self->{"endlen"}) lt $self->{"end"}
Truth table100%3/3
not(A) or B
A= not defined $lineB= substr($line, 0, $self->{"endlen"}) lt $self->{"end"}
| |||||||||||||||||||||||||||||
| 48 | 9 | $self->{'stage'} = 2; | |||||||||||||||||||||||||||
| 49 | 9 | return; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 2 | 1; | |||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||