line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Term::TtyRec; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
39938
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
113
|
|
4
|
3
|
|
|
3
|
|
17
|
use vars qw($VERSION); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
183
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.03'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
15
|
use IO::Handle; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
1147
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
3
|
|
|
3
|
0
|
130
|
my($proto, $io) = @_; |
11
|
3
|
|
33
|
|
|
24
|
my $class = ref $proto || $proto; |
12
|
3
|
50
|
|
|
|
28
|
unless ($io->can('read')) { |
13
|
0
|
|
|
|
|
0
|
require Carp; |
14
|
0
|
|
|
|
|
0
|
Carp::croak 'Usage: Term::TtyRec->new($io)'; |
15
|
|
|
|
|
|
|
} |
16
|
3
|
|
|
|
|
62
|
bless { handle => $io }, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub read_next { |
20
|
35
|
|
|
35
|
1
|
556
|
my $self = shift; |
21
|
35
|
|
|
|
|
54
|
my($sec, $text); |
22
|
35
|
|
|
|
|
57
|
eval { |
23
|
35
|
|
|
|
|
100
|
($sec, my $length) = $self->_read_header; |
24
|
29
|
|
|
|
|
112
|
$self->{handle}->read($text, $length); |
25
|
|
|
|
|
|
|
}; |
26
|
35
|
100
|
|
|
|
378
|
if ($@) { |
27
|
6
|
|
|
|
|
47
|
$self->{handle}->clearerr; |
28
|
6
|
|
|
|
|
52
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
29
|
|
|
|
|
202
|
return $sec, $text; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _read_header { |
34
|
35
|
|
|
35
|
|
58
|
my $self = shift; |
35
|
35
|
100
|
|
|
|
250
|
$self->{handle}->read(my($data), 12) or die 'EOF'; |
36
|
29
|
|
|
|
|
394
|
my($sec, $usec, $length) = unpack 'VVV', $data; |
37
|
29
|
|
|
|
|
109
|
return $sec + $usec / 1_000_000, $length; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |