line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Range::Compare::Stream::Iterator::File; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
105660
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
140
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
115
|
|
5
|
4
|
|
|
4
|
|
3074
|
use IO::File; |
|
4
|
|
|
|
|
20403
|
|
|
4
|
|
|
|
|
845
|
|
6
|
4
|
|
|
4
|
|
29
|
use Carp qw(croak); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
199
|
|
7
|
4
|
|
|
4
|
|
20
|
use base qw(Data::Range::Compare::Stream::Iterator::Base); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2508
|
|
8
|
4
|
|
|
4
|
|
1969
|
use Data::Range::Compare::Stream; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
3153
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
11
|
|
|
11
|
1
|
59
|
sub NEW_FROM { $_[0]->{NEW_FROM} } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
124
|
|
|
124
|
0
|
2231
|
my ($class,%args)=@_; |
15
|
|
|
|
|
|
|
|
16
|
124
|
|
|
|
|
838
|
my $self=$class->SUPER::new(%args); |
17
|
|
|
|
|
|
|
|
18
|
124
|
|
|
|
|
383
|
$self->{pos}=0; |
19
|
124
|
|
|
|
|
217
|
my $has_next; |
20
|
|
|
|
|
|
|
|
21
|
124
|
100
|
|
|
|
443
|
if(defined($args{fh})) { |
|
|
100
|
|
|
|
|
|
22
|
88
|
|
|
|
|
213
|
$self->{fh}=$args{fh}; |
23
|
88
|
|
|
|
|
261
|
$self->{filename}=ref($args{fh}); |
24
|
88
|
|
|
|
|
152
|
my $fh=$self->{fh}; |
25
|
|
|
|
|
|
|
|
26
|
88
|
50
|
|
|
|
474
|
croak 'fh=>$fh does not suppot getline' unless $fh->can('getline'); |
27
|
|
|
|
|
|
|
|
28
|
88
|
|
|
|
|
2548
|
my $line=$fh->getline; |
29
|
88
|
|
|
|
|
9364
|
$self->{next_line}=$line; |
30
|
88
|
|
|
|
|
251
|
$has_next=defined($line); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} elsif(defined($args{filename})) { |
33
|
34
|
|
|
|
|
230
|
my $fh=IO::File->new($args{filename},'r'); |
34
|
34
|
50
|
|
|
|
3481
|
if($fh) { |
35
|
34
|
|
|
|
|
145
|
$self->{fh}=$fh; |
36
|
34
|
|
|
|
|
914
|
my $line=$fh->getline; |
37
|
34
|
|
|
|
|
1366
|
$self->{next_line}=$line; |
38
|
34
|
|
|
|
|
65
|
$has_next=defined($line); |
39
|
34
|
|
|
|
|
82
|
$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
|
|
|
|
|
8
|
$self->{msg}="filename=>undef"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
124
|
|
|
|
|
280
|
$self->{has_next}=$has_next; |
49
|
124
|
|
|
|
|
510
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub get_size { |
53
|
1
|
|
|
1
|
1
|
3
|
my ($self)=@_; |
54
|
1
|
50
|
|
|
|
7
|
return $self->{size} if defined($self->{size}); |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
5
|
my $fh=$self->get_fh; |
57
|
1
|
|
|
|
|
4
|
my $pos=tell($fh); |
58
|
1
|
|
|
|
|
9
|
seek($fh,0,0); |
59
|
1
|
|
|
|
|
2
|
my $size=0; |
60
|
1
|
|
|
|
|
31
|
while($fh->getline) { |
61
|
4
|
|
|
|
|
248
|
++$size; |
62
|
|
|
|
|
|
|
} |
63
|
1
|
|
|
|
|
35
|
$self->{size}=$size; |
64
|
1
|
|
|
|
|
7
|
seek($fh,$pos,0); |
65
|
1
|
|
|
|
|
5
|
$size; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
5
|
|
|
5
|
1
|
30
|
sub get_pos { $_[0]->{pos} } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub in_error { |
71
|
18
|
|
|
18
|
0
|
971
|
my ($self)=@_; |
72
|
18
|
100
|
|
|
|
67
|
return 1 if defined($self->{msg}); |
73
|
16
|
|
|
|
|
72
|
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
|
80972
|
my ($self)=@_; |
85
|
61516
|
50
|
|
|
|
150885
|
return undef unless $self->has_next; |
86
|
61516
|
|
|
|
|
104259
|
++$self->{pos}; |
87
|
|
|
|
|
|
|
|
88
|
61516
|
|
|
|
|
96780
|
my $line=$self->{next_line}; |
89
|
61516
|
|
|
|
|
1708657
|
$self->{next_line}=$self->{fh}->getline; |
90
|
61516
|
|
|
|
|
1936949
|
$self->{has_next}=defined($self->{next_line}); |
91
|
|
|
|
|
|
|
|
92
|
61516
|
|
|
|
|
68451
|
return $self->create_from_factory(@{$self->parse_line($line)}); |
|
61516
|
|
|
|
|
173345
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
3
|
|
|
3
|
0
|
21
|
sub get_fh { $_[0]->{fh} } |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
2
|
0
|
13
|
sub created_fh { $_[0]->{created_fh} } |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub DESTROY { |
100
|
124
|
|
|
124
|
|
4352
|
my ($self)=@_; |
101
|
124
|
50
|
|
|
|
328
|
return unless defined($self); |
102
|
124
|
100
|
|
|
|
376
|
return unless defined($self->{fh}); |
103
|
122
|
100
|
|
|
|
1026
|
return unless $self->{created_fh}; |
104
|
34
|
|
|
|
|
228
|
$self->{fh}->close; |
105
|
34
|
|
|
|
|
103587
|
$self->{fh}=undef; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |