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