line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Range::Compare::Stream::Iterator::File; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
90220
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
100
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
104
|
|
5
|
4
|
|
|
4
|
|
1649
|
use IO::File; |
|
4
|
|
|
|
|
13627
|
|
|
4
|
|
|
|
|
726
|
|
6
|
4
|
|
|
4
|
|
24
|
use Carp qw(croak); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
174
|
|
7
|
4
|
|
|
4
|
|
26
|
use base qw(Data::Range::Compare::Stream::Iterator::Base); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
2210
|
|
8
|
4
|
|
|
4
|
|
1934
|
use Data::Range::Compare::Stream; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
3164
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
11
|
|
|
11
|
1
|
42
|
sub NEW_FROM { $_[0]->{NEW_FROM} } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
124
|
|
|
124
|
0
|
1685
|
my ($class,%args)=@_; |
15
|
|
|
|
|
|
|
|
16
|
124
|
|
|
|
|
702
|
my $self=$class->SUPER::new(%args); |
17
|
|
|
|
|
|
|
|
18
|
124
|
|
|
|
|
324
|
$self->{pos}=0; |
19
|
124
|
|
|
|
|
172
|
my $has_next; |
20
|
|
|
|
|
|
|
|
21
|
124
|
100
|
|
|
|
362
|
if(defined($args{fh})) { |
|
|
100
|
|
|
|
|
|
22
|
88
|
|
|
|
|
172
|
$self->{fh}=$args{fh}; |
23
|
88
|
|
|
|
|
220
|
$self->{filename}=ref($args{fh}); |
24
|
88
|
|
|
|
|
161
|
my $fh=$self->{fh}; |
25
|
|
|
|
|
|
|
|
26
|
88
|
50
|
|
|
|
434
|
croak 'fh=>$fh does not suppot getline' unless $fh->can('getline'); |
27
|
|
|
|
|
|
|
|
28
|
88
|
|
|
|
|
2162
|
my $line=$fh->getline; |
29
|
88
|
|
|
|
|
3434
|
$self->{next_line}=$line; |
30
|
88
|
|
|
|
|
180
|
$has_next=defined($line); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} elsif(defined($args{filename})) { |
33
|
34
|
|
|
|
|
195
|
my $fh=IO::File->new($args{filename},'r'); |
34
|
34
|
50
|
|
|
|
2930
|
if($fh) { |
35
|
34
|
|
|
|
|
119
|
$self->{fh}=$fh; |
36
|
34
|
|
|
|
|
892
|
my $line=$fh->getline; |
37
|
34
|
|
|
|
|
1309
|
$self->{next_line}=$line; |
38
|
34
|
|
|
|
|
64
|
$has_next=defined($line); |
39
|
34
|
|
|
|
|
73
|
$self->{created_fh}=1; |
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
|
|
|
|
0
|
$self->{msg}="Error could not open $args{filename} error was: $!"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} else { |
45
|
2
|
|
|
|
|
6
|
$self->{msg}="filename=>undef"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
124
|
|
|
|
|
288
|
$self->{has_next}=$has_next; |
49
|
124
|
|
|
|
|
474
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub get_size { |
53
|
1
|
|
|
1
|
1
|
2
|
my ($self)=@_; |
54
|
1
|
50
|
|
|
|
6
|
return $self->{size} if defined($self->{size}); |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
4
|
my $fh=$self->get_fh; |
57
|
1
|
|
|
|
|
8
|
my $pos=tell($fh); |
58
|
1
|
|
|
|
|
5
|
seek($fh,0,0); |
59
|
1
|
|
|
|
|
2
|
my $size=0; |
60
|
1
|
|
|
|
|
27
|
while($fh->getline) { |
61
|
4
|
|
|
|
|
187
|
++$size; |
62
|
|
|
|
|
|
|
} |
63
|
1
|
|
|
|
|
31
|
$self->{size}=$size; |
64
|
1
|
|
|
|
|
3
|
seek($fh,$pos,0); |
65
|
1
|
|
|
|
|
6
|
$size; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
5
|
|
|
5
|
1
|
23
|
sub get_pos { $_[0]->{pos} } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub in_error { |
71
|
18
|
|
|
18
|
0
|
698
|
my ($self)=@_; |
72
|
18
|
100
|
|
|
|
70
|
return 1 if defined($self->{msg}); |
73
|
16
|
|
|
|
|
57
|
return 0; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
0
|
0
|
sub get_error { $_[0]->{msg} } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub to_string { |
79
|
0
|
|
|
0
|
1
|
0
|
my ($self)=@_; |
80
|
0
|
|
|
|
|
0
|
return $self->{filename}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_next { |
84
|
61516
|
|
|
61516
|
1
|
82965
|
my ($self)=@_; |
85
|
61516
|
50
|
|
|
|
151642
|
return undef unless $self->has_next; |
86
|
61516
|
|
|
|
|
101907
|
++$self->{pos}; |
87
|
|
|
|
|
|
|
|
88
|
61516
|
|
|
|
|
96507
|
my $line=$self->{next_line}; |
89
|
61516
|
|
|
|
|
1413865
|
$self->{next_line}=$self->{fh}->getline; |
90
|
61516
|
|
|
|
|
1685838
|
$self->{has_next}=defined($self->{next_line}); |
91
|
|
|
|
|
|
|
|
92
|
61516
|
|
|
|
|
80131
|
return $self->create_from_factory(@{$self->parse_line($line)}); |
|
61516
|
|
|
|
|
173233
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
3
|
|
|
3
|
0
|
18
|
sub get_fh { $_[0]->{fh} } |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
2
|
0
|
13
|
sub created_fh { $_[0]->{created_fh} } |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub DESTROY { |
100
|
124
|
|
|
124
|
|
2434
|
my ($self)=@_; |
101
|
124
|
50
|
|
|
|
350
|
return unless defined($self); |
102
|
124
|
100
|
|
|
|
334
|
return unless defined($self->{fh}); |
103
|
122
|
100
|
|
|
|
964
|
return unless $self->{created_fh}; |
104
|
34
|
|
|
|
|
172
|
$self->{fh}->close; |
105
|
34
|
|
|
|
|
2008
|
$self->{fh}=undef; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |