line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tie::Handle::TtyRec; |
2
|
4
|
|
|
4
|
|
89033
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
185
|
|
3
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
125
|
|
4
|
4
|
|
|
4
|
|
29
|
use base 'Tie::Handle'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
3815
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
15829
|
use Symbol; |
|
4
|
|
|
|
|
3866
|
|
|
4
|
|
|
|
|
306
|
|
7
|
4
|
|
|
4
|
|
1402981
|
use Time::HiRes 'gettimeofday'; |
|
4
|
|
|
|
|
14446
|
|
|
4
|
|
|
|
|
26
|
|
8
|
4
|
|
|
4
|
|
817
|
use Carp 'croak'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
5140
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
4
|
|
|
4
|
0
|
128
|
my ($class, $filename, %params) = @_; |
14
|
4
|
|
|
|
|
53
|
my $symbol = Symbol::gensym; |
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
|
|
87
|
tie(*$symbol, __PACKAGE__, $filename, %params); |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
|
|
14
|
return $symbol; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub TIEHANDLE { |
22
|
4
|
|
|
4
|
|
11
|
my ($class, $filename, %params) = @_; |
23
|
|
|
|
|
|
|
|
24
|
4
|
100
|
|
|
|
126
|
my $mode = -p $filename ? '+>' |
|
|
50
|
|
|
|
|
|
25
|
|
|
|
|
|
|
: $params{append} ? '>>' |
26
|
|
|
|
|
|
|
: '>'; |
27
|
|
|
|
|
|
|
|
28
|
4
|
50
|
|
|
|
368
|
open(my $self, $mode, $filename) |
29
|
|
|
|
|
|
|
or croak "Unable to open $filename for writing: $!"; |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
50
|
$self->autoflush(1); |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
33
|
|
|
248
|
bless $self, (ref $class || $class); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub READ { |
37
|
0
|
|
|
0
|
|
0
|
croak "Cannot read from a Tie::Handle::TtyRec"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub WRITE { |
41
|
21
|
|
|
21
|
|
262
|
my $self = shift; |
42
|
21
|
|
|
|
|
33
|
my ($buf, $length, $offset) = @_; |
43
|
21
|
|
100
|
|
|
78
|
$offset ||= 0; |
44
|
21
|
|
66
|
|
|
71
|
$length ||= length($buf) - $offset; |
45
|
21
|
|
|
|
|
66
|
syswrite $self, pack('VVV', gettimeofday, $length) |
46
|
|
|
|
|
|
|
. substr($buf, $offset, $length); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub PRINT { |
50
|
8
|
|
|
8
|
|
385
|
my $self = shift; |
51
|
8
|
|
|
|
|
27
|
$self->WRITE($_) for @_; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub CLOSE { |
55
|
4
|
|
|
4
|
|
83
|
my $self = shift; |
56
|
4
|
|
|
|
|
49
|
close $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |