line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TimelogTxt::File; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
78407
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
610
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.22'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
14
|
|
|
14
|
1
|
7771
|
my ($class, $fh, $start, $end) = @_; |
10
|
|
|
|
|
|
|
|
11
|
14
|
100
|
|
|
|
51
|
die "Missing required file handle or file name.\n" unless defined $fh; |
12
|
13
|
100
|
|
|
|
34
|
die "Missing required start marker.\n" unless defined $start; |
13
|
12
|
100
|
|
|
|
37
|
die "Missing required end marker.\n" unless defined $end; |
14
|
11
|
50
|
|
|
|
27
|
if( !ref $fh ) { |
15
|
0
|
|
|
|
|
0
|
my $name = $fh; |
16
|
0
|
0
|
|
|
|
0
|
open( $fh, '<', $name ) or die "Unable to open file '$name': $!\n"; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
11
|
|
|
|
|
58
|
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
|
|
|
|
|
42
|
return bless $obj, $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub readline { |
32
|
43
|
|
|
43
|
1
|
102
|
my ($self) = @_; |
33
|
|
|
|
|
|
|
|
34
|
43
|
100
|
100
|
|
|
311
|
return if $self->{'stage'} > 1 or eof( $self->{'fh'} ); |
35
|
|
|
|
|
|
|
|
36
|
35
|
|
|
|
|
32
|
my $line; |
37
|
35
|
100
|
|
|
|
72
|
if( $self->{'stage'} == 0 ) |
38
|
|
|
|
|
|
|
{ |
39
|
11
|
|
100
|
|
|
363
|
0 while( defined( $line = readline $self->{'fh'} ) && substr( $line, 0, $self->{'startlen'} ) lt $self->{'start'} ); |
40
|
11
|
|
|
|
|
20
|
$self->{'stage'} = 1; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else |
43
|
|
|
|
|
|
|
{ |
44
|
24
|
|
|
|
|
62
|
$line = readline $self->{'fh'}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
35
|
100
|
100
|
|
|
312
|
return $line if !defined $line || substr( $line, 0, $self->{'endlen'} ) lt $self->{'end'}; |
48
|
9
|
|
|
|
|
14
|
$self->{'stage'} = 2; |
49
|
9
|
|
|
|
|
61
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |