Pipe/Tube/Print.pm

filter: Statementstmt 93.1% 27 / 29 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 82.9% 39 / 47 CC 6 SCAR 11.4
CC
6
Cov
85%
init
5.3
run
2.1
BEGIN
1.0
CRAP 3.1
↑ Summary Pipe/Tube/Cat.pm »
1 package Pipe::Tube::Print;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base 'Pipe::Tube';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.06';
9  
10 4 ▶sub init {
Subroutine init: called CC=5 SCAR=16.6
Pod undocumented
11 4 my ($self, $file) = @_;
12 # file can be either undef -> STDOUT or a filehandle, or a filename -> print into that file,
13 4 ▶ if ($file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) 4 0 4
14 4 ▶ if (not ref $file) { # string, assume filename
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $file) { } 2 2 4
elsif ('GLOB' eq ref $file) { } 2 0 2
15 2 ▶ open my $fh, ">", $file or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $file or die $! 2 0 2
16 2 $self->{fh} = $fh;
17 2 $self->logger("Print: received filename");
18 } elsif ('GLOB' eq ref $file) { # filehandle
19 2 $self->{fh} = $file;
20 2 $self->logger("Print: received filehandle");
21 } else {
22 0 die "Unkown type of paramter for print: '" . ref($file) . "'\n";
23 }
24 }
25 4 return $self;
26 }
27  
28 28 ▶sub run {
Subroutine run: called CC=2 SCAR=7.2
Pod undocumented
29 28 my ($self, @input) = @_;
30 28 $self->logger("Print: @input");
31 28 ▶ if (my $fh = $self->{fh}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fh = $self->{'fh'}) { } 28 0 28
32 28 print $fh @input;
33 } else {
34 0 print @input;
35 }
36 28 return;
37 }
38  
39  
40 1 1;
41  
↑ Summary Pipe/Tube/Cat.pm »