line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::APL::Reader; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
69417
|
use strict; |
|
3
|
|
|
|
|
19
|
|
|
3
|
|
|
|
|
86
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
79
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
14
|
use base 'Text::APL::Base'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1254
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub build { |
9
|
24
|
|
|
24
|
1
|
67
|
my $self = shift; |
10
|
24
|
|
|
|
|
42
|
my ($input) = @_; |
11
|
|
|
|
|
|
|
|
12
|
24
|
|
|
|
|
28
|
my $reader; |
13
|
|
|
|
|
|
|
|
14
|
24
|
100
|
|
|
|
98
|
if (!ref $input) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
15
|
1
|
|
|
|
|
6
|
$reader = $self->_build_file_reader($input); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
elsif (ref $input eq 'GLOB') { |
18
|
1
|
|
|
|
|
4
|
$reader = $self->_build_file_handle_reader($input); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
elsif (ref $input eq 'SCALAR') { |
21
|
21
|
|
|
|
|
50
|
$reader = $self->_build_string_reader($input); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
elsif (ref $input eq 'CODE') { |
24
|
1
|
|
|
|
|
2
|
$reader = $input; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
0
|
|
|
|
|
0
|
die 'Do not know how to read'; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
24
|
|
|
|
|
59
|
return $reader; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _build_file_reader { |
34
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
35
|
1
|
|
|
|
|
23
|
my ($input) = @_; |
36
|
|
|
|
|
|
|
|
37
|
1
|
50
|
|
|
|
48
|
open my $fh, '<', $input or die "Can't open '$input': $!"; |
38
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
12
|
if (my $charset = $self->{charset}) { |
40
|
1
|
|
|
1
|
|
29
|
binmode $fh, ":encoding($charset)"; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
12862
|
return $self->_build_file_handle_reader($fh); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _build_file_handle_reader { |
47
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
48
|
2
|
|
|
|
|
5
|
my ($input) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub { |
51
|
2
|
|
|
2
|
|
23
|
my ($cb) = @_; |
52
|
2
|
|
|
|
|
63
|
while (defined(my $line = <$input>)) { |
53
|
2
|
|
|
|
|
35
|
$cb->($line); |
54
|
|
|
|
|
|
|
} |
55
|
2
|
|
|
|
|
34
|
$cb->(); |
56
|
2
|
|
|
|
|
15
|
}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _build_string_reader { |
60
|
21
|
|
|
21
|
|
28
|
my $self = shift; |
61
|
21
|
|
|
|
|
32
|
my ($input) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub { |
64
|
21
|
|
|
21
|
|
42
|
my ($cb) = @_; |
65
|
|
|
|
|
|
|
|
66
|
21
|
|
|
|
|
28
|
$cb->(${$input}); |
|
21
|
|
|
|
|
56
|
|
67
|
21
|
|
|
|
|
56
|
$cb->(); |
68
|
21
|
|
|
|
|
83
|
}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__END__ |