| 1 | package Tie::Handle::TtyRec; | ||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 4 | ▶ | use base 'Tie::Handle'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 4 | ▶ | use Symbol; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 4 | ▶ | use Time::HiRes 'gettimeofday'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 4 | ▶ | use Carp 'croak'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 4 | our $VERSION = '0.04'; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 4 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 13 | 4 | my ($class, $filename, %params) = @_; | |||||||||||||||||||
| 14 | 4 | my $symbol = Symbol::gensym; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 4 | tie(*$symbol, __PACKAGE__, $filename, %params); | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 4 | return $symbol; | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 4 | ▶ | sub TIEHANDLE { | ||||||||||||||||||
|
Subroutine
TIEHANDLE: called CC=5 SCAR=17.2
| |||||||||||||||||||||
| 22 | 4 | my ($class, $filename, %params) = @_; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | my $mode = -p $filename ? '+>' | ||||||||||||||||||||
| 25 | 4 | ▶ | : $params{append} ? '>>' | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 26 | : '>'; | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 4 | ▶ | open(my $self, $mode, $filename) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | or croak "Unable to open $filename for writing: $!"; | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 4 | $self->autoflush(1); | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 4 | ▶ | bless $self, (ref $class || $class); | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | sub READ { | ||||||||||||||||||
|
Subroutine
READ: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 37 | 0 | croak "Cannot read from a Tie::Handle::TtyRec"; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 21 | ▶ | sub WRITE { | ||||||||||||||||||
|
Subroutine
WRITE: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 41 | 21 | my $self = shift; | |||||||||||||||||||
| 42 | 21 | my ($buf, $length, $offset) = @_; | |||||||||||||||||||
| 43 | 21 | ▶ | $offset ||= 0; | ||||||||||||||||||
|
Condition100%2/2
$offset ||= 0
MC/DC100%1/1
$offset ||= 0
$offset
Truth table100%2/2
A
A= $offset
| |||||||||||||||||||||
| 44 | 21 | ▶ | $length ||= length($buf) - $offset; | ||||||||||||||||||
|
Condition66%2/3
$length ||= length($buf) - $offset
MC/DC0%0/2
$length ||= length($buf) - $offset
$length
length($buf) - $offset
Truth table66%2/3
A ||= B
A= $lengthB= length($buf) - $offset
| |||||||||||||||||||||
| 45 | 21 | syswrite $self, pack('VVV', gettimeofday, $length) | |||||||||||||||||||
| 46 | . substr($buf, $offset, $length); | ||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 8 | ▶ | sub PRINT { | ||||||||||||||||||
|
Subroutine
PRINT: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 50 | 8 | my $self = shift; | |||||||||||||||||||
| 51 | 8 | $self->WRITE($_) for @_; | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 4 | ▶ | sub CLOSE { | ||||||||||||||||||
|
Subroutine
CLOSE: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 55 | 4 | my $self = shift; | |||||||||||||||||||
| 56 | 4 | close $self; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 4 | 1; | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||