| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 2 | ## MIME Email Builder - ~/lib/Mail/Make/Stream.pm | ||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.1.0 | ||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2026 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2026/03/05 | ||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2026/03/05 | ||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 10 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 11 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 12 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 13 | package Mail::Make::Stream; | ||||||||||||||||||||||||||||||||||||||||||
| 14 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | warnings::register_categories( 'Mail::Make' ); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use vars qw( $VERSION $EXCEPTION_CLASS ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 8 | ▶ | use Mail::Make::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 8 | our $EXCEPTION_CLASS = 'Mail::Make::Exception'; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | our $VERSION = 'v0.1.0'; | |||||||||||||||||||||||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | sub init | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $self->{_exception_class} = $EXCEPTION_CLASS; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | # NOTE: STORABLE support | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # NOTE: FREEZE is inherited | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub STORABLE_freeze { CORE::return( CORE::shift->FREEZE( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub STORABLE_thaw { CORE::return( CORE::shift->THAW( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # NOTE: THAW is inherited | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | # NOTE: Mail::Make::Stream::Generic inline class | ||||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | package | ||||||||||||||||||||||||||||||||||||||||||
| 53 | Mail::Make::Stream::Generic; | ||||||||||||||||||||||||||||||||||||||||||
| 54 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 8 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 8 | ▶ | use vars qw( $VERSION $EXCEPTION_CLASS ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 8 | ▶ | use Mail::Make::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | use Module::Generic::File::IO; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | ▶ | use Module::Generic::Scalar::IO; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 8 | our $EXCEPTION_CLASS = 'Mail::Make::Exception'; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 8 | our $VERSION = $Mail::Make::Stream::VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | sub init | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 64 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 64 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 64 | ▶ | my $class = ( ref( $self ) || $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 64 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 64 | $self->{_exception_class} = defined( ${"${class}::EXCEPTION_CLASS"} ) | |||||||||||||||||||||||||||||||||||||||||
| 77 | 64 | ▶ | ? ${"${class}::EXCEPTION_CLASS"} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | : $EXCEPTION_CLASS; | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 64 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 64 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | # _get_glob_from_arg( $source_or_dest [, write => 1] ) | ||||||||||||||||||||||||||||||||||||||||||
| 84 | # | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # Normalises any of the following into a ( $fh, $op ) pair: | ||||||||||||||||||||||||||||||||||||||||||
| 86 | # | ||||||||||||||||||||||||||||||||||||||||||
| 87 | # - A native Perl glob / IO object → used directly | ||||||||||||||||||||||||||||||||||||||||||
| 88 | # - A scalar reference (\$scalar) → Module::Generic::Scalar::IO | ||||||||||||||||||||||||||||||||||||||||||
| 89 | # - A plain string (file path) → Module::Generic::File opened via new_file() | ||||||||||||||||||||||||||||||||||||||||||
| 90 | # | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # $op is a closure that: | ||||||||||||||||||||||||||||||||||||||||||
| 92 | # Read mode: $op->( $buf, $len ) - returns bytes read (0 at EOF, undef on error) | ||||||||||||||||||||||||||||||||||||||||||
| 93 | # Write mode: $op->( $data ) - returns true on success, undef on error | ||||||||||||||||||||||||||||||||||||||||||
| 94 | sub _get_glob_from_arg | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 142 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_glob_from_arg: called CC=27 SCAR=49.5
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 142 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 97 | 142 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 142 | ▶ | if( !defined( $this ) || ( !ref( $this ) && !length( $this ) ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $this and ref $this || length $this
ref $this or length $this
MC/DC0%0/3
defined $this and ref $this || length $this
defined $this
ref $this
length $this
Truth table25%1/4
A and B or C
A= defined $thisB= ref $thisC= length $this
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | return( $self->error( "No argument was provided." ) ); | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 142 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 142 | ▶ | $opts->{write} = 0 if( !exists( $opts->{write} ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 142 | ▶ | my $mode = $opts->{write} ? '+>' : '<'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 142 | my $fh; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 142 | my $is_native_glob = 0; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 142 | ▶ | if( $self->_is_glob( $this ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 58 | $fh = $this; | |||||||||||||||||||||||||||||||||||||||||
| 111 | # Even if this is an in-memory scalar handle, fileno() returns -1, which is true | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 58 | ▶ | $is_native_glob++ if( fileno( $this ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | elsif( $self->_is_scalar( $this ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 72 | ▶ | $fh = Module::Generic::Scalar::IO->new( $this, $mode ) || | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'Module::Generic::Scalar::IO'->new($this, $mode) || (return $self->pass_error('Module::Generic::Scalar::IO'->error))
MC/DC0%0/1
'Module::Generic::Scalar::IO'->new($this, $mode) || (return $self->pass_error('Module::Generic::Scalar::IO'->error))
'Module::Generic::Scalar::IO'->new($this, $mode)
Truth table50%1/2
A
A= 'Module::Generic::Scalar::IO'->new($this, $mode)
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | return( $self->pass_error( Module::Generic::Scalar::IO->error ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 72 | $is_native_glob++; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | else | ||||||||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 12 | ▶ | my $f = $self->new_file( "$this" ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->new_file("$this") || (return $self->pass_error)
MC/DC0%0/1
$self->new_file("$this") || (return $self->pass_error)
$self->new_file("$this")
Truth table50%1/2
A
A= $self->new_file("$this")
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 12 | ▶ | if( !$f->exists && !$opts->{write} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$f->exists or $opts->{"write"}
MC/DC0%0/2
$f->exists or $opts->{"write"}
$f->exists
$opts->{"write"}
Truth table33%1/3
A or B
A= $f->existsB= $opts->{"write"}
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | return( $self->error( "File '$this' does not exist." ) ); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 12 | ▶ | $fh = $f->open( $mode, { binmode => 'raw', ( $opts->{write} ? ( autoflush => 1 ) : () ) } ) || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$f->open($mode, {'binmode', 'raw', $opts->{'write'} ? ('autoflush', 1) : ()}) || (return $self->pass_error($f->error))
MC/DC0%0/1
$f->open($mode, {'binmode', 'raw', $opts->{'write'} ? ('autoflush', 1) : ()}) || (return $self->pass_error($f->error))
$f->open($mode, {'binmode', 'raw', $opts->{'write'} ? ('autoflush', 1) : ()})
Truth table50%1/2
A
A= $f->open($mode, {'binmode', 'raw', $opts->{'write'} ? ('autoflush', 1) : ()})
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | return( $self->pass_error( $f->error ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 12 | $is_native_glob++; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 142 | my $flags; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 142 | ▶ | if( $self->_can( $fh => 'fcntl' ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 96 | $flags = $fh->fcntl( F_GETFL, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | else | ||||||||||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 46 | $flags = fcntl( $fh, F_GETFL, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 142 | ▶ | if( defined( $flags ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 96 | ▶ | if( $opts->{write} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 71 | ▶ | unless( $flags & ( O_RDWR | O_WRONLY | O_APPEND ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return( $self->error( "Filehandle provided does not have write permission enabled." ) ); | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | else | ||||||||||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 25 | ▶ | unless( ( ( $flags & O_RDONLY ) == O_RDONLY ) || ( $flags & O_RDWR ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
($flags & 0) == 0 or $flags & 2
MC/DC0%0/2
($flags & 0) == 0 or $flags & 2
($flags & 0) == 0
$flags & 2
Truth table33%1/3
A or B
A= ($flags & 0) == 0B= $flags & 2
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return( $self->error( "Filehandle provided does not have read permission enabled. File handle flags value is '$flags'" ) ); | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | # We check if the file handle is an object, because calling core read() or print() | ||||||||||||||||||||||||||||||||||||||||||
| 161 | # on it would not work unless the glob has implemented a tie. See perltie. | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 142 | my $op; | |||||||||||||||||||||||||||||||||||||||||
| 163 | my $meth; | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 142 | ▶ | if( $opts->{write} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 71 | ▶ | if( $is_native_glob ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | $op = sub | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 77 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 77 | my $rv = print( $fh @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 77 | ▶ | return( $self->error( "Error writing ", CORE::length( $_[0] ), " bytes of data to output: $!" ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | if( !defined( $rv ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 77 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 71 | }; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | ▶ | elsif( ( $meth = ( $self->_can( $fh => 'print' ) || $self->_can( $fh => 'write' ) ) ) ) | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->_can($fh, 'print') || $self->_can($fh, 'write')
MC/DC0%0/2
$self->_can($fh, 'print') || $self->_can($fh, 'write')
$self->_can($fh, 'print')
$self->_can($fh, 'write')
Truth table0%0/3
A || B
A= $self->_can($fh, 'print')B= $self->_can($fh, 'write')
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | $op = sub | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $rv = eval{ $fh->$meth( @_ ) }; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | return( $self->error( "Error writing ", CORE::length( $_[0] ), " bytes of data to output: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if( !defined( $rv ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my $err; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if( defined( $! ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | { | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $err = $!; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | elsif( $self->_can( $fh => 'error' ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $err = $fh->error; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | elsif( $self->_can( $fh => 'errstr' ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 198 | { | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $err = $fh->errstr; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | return( $self->error( "Error writing ", CORE::length( $_[0] ), " bytes of data to output: $err" ) ); | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | else | ||||||||||||||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | return( $self->error( "The file handle provided is not a native opened one and does not support the print() or write() methods." ) ); | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | else | ||||||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 71 | ▶ | if( $is_native_glob ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | $op = sub | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 47 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 47 | my $n = read( $fh, $_[0], $_[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 218 | 47 | ▶ | if( !defined( $n ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | return( $self->error( "Error reading ", $_[1], " bytes of data from input: $!" ) ); | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 47 | return( $n ); | |||||||||||||||||||||||||||||||||||||||||
| 223 | 71 | }; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | elsif( $self->_can( $fh => 'read' ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 226 | { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | $op = sub | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $n = eval{ $fh->read( @_ ) }; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return( $self->error( "Error reading ", $_[1], " bytes of data from input: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if( !defined( $n ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | { | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $err; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if( defined( $! ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $err = $!; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | elsif( $self->_can( $fh => 'error' ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 243 | { | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $err = $fh->error; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | elsif( $self->_can( $fh => 'errstr' ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $err = $fh->errstr; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | return( $self->error( "Error reading ", $_[1], " bytes of data from input: $err" ) ); | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return( $n ); | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | else | ||||||||||||||||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | return( $self->error( "The file handle provided is not a native opened one and does not support the read() method." ) ); | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 142 | return( $fh, $op ); | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | # NOTE: sub FREEZE is inherited | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub STORABLE_freeze { CORE::return( CORE::shift->FREEZE( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub STORABLE_thaw { CORE::return( CORE::shift->THAW( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | # NOTE: sub THAW is inherited | ||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 273 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||
| 274 | __END__ | ||||||||||||||||||||||||||||||||||||||||||