Die/print.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 31 / 31 CC 7 SCAR 18.3
CC
7
Cov
100%
print
7.0
BEGIN
1.0
CRAP 6.2
« Die/syswrite.pm ↑ Summary Die/lstat.pm »
1 package IO::Die;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 #A bit more restrictive than Perl’s built-in print():
6 # - A file handle is still optional, but it MUST be a reference.
7 #
8 #This does still fall back to $_ and does still use the default file handle
9 #if either the LIST or FILEHANDLE is omitted (cf. perldoc -f print).
10 #
11 47 ▶sub print {
Subroutine print: called CC=7 SCAR=19.5
12 47 my ( $NS, $args_ar ) = ( shift, \@_ );
13  
14 47 local ( $!, $^E );
15  
16 47 my $ret;
17 47 ▶ if ( __is_a_fh( $args_ar->[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (__is_a_fh($args_ar->[0])) { } 34 13 47
18 34 ▶ $ret = CORE::print { shift @$args_ar } ( @$args_ar ? @$args_ar : $_ );
Branch: 1 branch
BranchTrueFalseTotal
@$args_ar ? : 26 8 34
19 }
20 else {
21 13 ▶ $ret = CORE::print( @$args_ar ? @$args_ar : $_ );
Branch: 1 branch
BranchTrueFalseTotal
@$args_ar ? : 9 4 13
22 }
23  
24 47 ▶ if ($^E) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^E) 8 39 47
25  
26 #Figure out the "length" to report to the exception object.
27 8 my $length;
28 8 ▶ if (@$args_ar) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$args_ar) { } 4 4 8
29 4 $length = 0;
30 4 $length += length for @$args_ar;
31 }
32 else {
33 4 $length = length;
34 }
35  
36 8 $NS->__THROW( 'Write', length => $length );
37 }
38  
39 39 return $ret;
40 }
41  
42 7 1;
« Die/syswrite.pm ↑ Summary Die/lstat.pm »