| 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
| |||||||||||
| 18 | 34 | ▶ | $ret = CORE::print { shift @$args_ar } ( @$args_ar ? @$args_ar : $_ ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | } | ||||||||||
| 20 | else { | ||||||||||
| 21 | 13 | ▶ | $ret = CORE::print( @$args_ar ? @$args_ar : $_ ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 47 | ▶ | if ($^E) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | #Figure out the "length" to report to the exception object. | ||||||||||
| 27 | 8 | my $length; | |||||||||
| 28 | 8 | ▶ | if (@$args_ar) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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; | |||||||||