| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Module Generic - ~/lib/Module/Generic/Scalar.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v1.4.4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2025 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2021/03/20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2026/01/22 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 Module::Generic::Scalar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 16 | ▶ | use v5.16.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 16 | ▶ | use common::sense; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 16 | warnings::register_categories( 'Module::Generic' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 16 | ▶ | use vars qw( $DEBUG $ERROR ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 16 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 16 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 16 | ▶ | use Module::Generic::Global ':const'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # So that the user can say $obj->isa( 'Module::Generic::Scalar' ) and it would return true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # use parent -norequire, qw( Module::Generic::Scalar ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 16 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 16 | ▶ | use Wanted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 16 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | '""' => 'as_string', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | '.=' => sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | my( $self, $other, $swap ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 16 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | if( !CORE::defined( $$self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | elsif( !CORE::defined( $other ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | return( $$self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | my $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | ▶ | if( $swap ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $expr = "\$other .= \$$self"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | return( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | $$self .= $other; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'x' => sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | my( $self, $other, $swap ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 16 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | my $expr = $swap ? "\"$other\" x \"$$self\"" : "\"$$self\" x \"$other\""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | my $res = eval( $expr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | CORE::warn( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | return( $self->new( $res ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 'eq' => sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 135 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 135 | my( $self, $other, $swap ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 16 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 135 | ▶ | if( Scalar::Util::blessed( $other ) && ref( $other ) eq ref( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($other) and ref $other eq ref $self
MC/DC50%1/2
builtin::blessed($other) and ref $other eq ref $self
builtin::blessed($other)
ref $other eq ref $self
Truth table66%2/3
A and B
A= builtin::blessed($other)B= ref $other eq ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 9 | return( $$self eq $$other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 126 | return( $$self eq "$other" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 16 | fallback => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 16 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 16 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 16 | ▶ | if( defined( ${^GLOBAL_PHASE} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # perl 5.14+: use the built-in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 16 | ▶ | eval q{ sub _in_global_destruction () { ${^GLOBAL_PHASE} eq 'DESTRUCT' } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_in_global_destruction: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # perl < 5.14: detect via B::main_cv. During global destruction, PL_main_cv is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # set to Nullcv, which B exposes as a B::SPECIAL whose dereferenced value is 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | require B; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | eval q{ sub _in_global_destruction () { ${B::main_cv()} == 0 } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 16 | ▶ | die( $@ ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 16 | $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 16 | our $VERSION = 'v1.4.4'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 16 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 16 | require Module::Generic::Array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 16 | require Module::Generic::Boolean; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 16 | require Module::Generic::Null; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 16 | require Module::Generic::Number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # sub new { return( shift->_new( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 504 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=24.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 504 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 504 | ▶ | my $class = ref( $this ) || $this; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table66%2/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 504 | my $init = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 504 | ▶ | if( ref( $_[0] ) eq 'SCALAR' || UNIVERSAL::isa( $_[0], 'SCALAR' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
ref $_[0] eq "SCALAR" or UNIVERSAL::isa($_[0], "SCALAR")
MC/DC50%1/2
ref $_[0] eq "SCALAR" or UNIVERSAL::isa($_[0], "SCALAR")
ref $_[0] eq "SCALAR"
UNIVERSAL::isa($_[0], "SCALAR")
Truth table66%2/3
A or B
A= ref $_[0] eq "SCALAR"B= UNIVERSAL::isa($_[0], "SCALAR")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | $init = ${$_[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ▶ | elsif( ref( $_[0] ) eq 'ARRAY' || UNIVERSAL::isa( $_[0], 'ARRAY' ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $_[0] eq "ARRAY" or UNIVERSAL::isa($_[0], "ARRAY")
MC/DC0%0/2
ref $_[0] eq "ARRAY" or UNIVERSAL::isa($_[0], "ARRAY")
ref $_[0] eq "ARRAY"
UNIVERSAL::isa($_[0], "ARRAY")
Truth table33%1/3
A or B
A= ref $_[0] eq "ARRAY"B= UNIVERSAL::isa($_[0], "ARRAY")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $init = CORE::join( '', @{$_[0]} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | elsif( ref( $_[0] ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return( $this->error( "I do not know what to do with \"", overload::StrVal( $_[0] ), "\". ${class} only supports string, scalar reference or array reference." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | elsif( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 502 | $init = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | $init = undef(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 504 | ▶ | return( bless( \$init => ( ref( $this ) || $this ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table66%2/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub append { ${$_[0]} .= ( ( Scalar::Util::reftype( $_[1] ) // '' ) eq 'SCALAR' ? ${$_[1]} : $_[1] ); return( $_[0] ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append: called CC=3 SCAR=12.5
Pod
documented
Branch: 1 branch
Condition50%1/2
builtin::reftype($_[1]) // ""
MC/DC0%0/1
builtin::reftype($_[1]) // ""
builtin::reftype($_[1])
Truth table50%1/2
A
A= builtin::reftype($_[1])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | sub as_array { return( Module::Generic::Array->new( [ ${$_[0]} ] ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_array: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5 | ▶ | sub as_boolean { return( Module::Generic::Boolean->new( ${$_[0]} ? 1 : 0 ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_boolean: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | sub as_number { return( $_[0]->_number( ${$_[0]} ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_number: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ## sub as_string { CORE::defined( ${$_[0]} ) ? return( ${$_[0]} ) : return; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3001 | ▶ | sub as_string { return( ${$_[0]} ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | sub callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
callback: called CC=15 SCAR=31.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 7 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7 | my( $what, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 7 | ▶ | if( !defined( $what ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return( $self->error( "No callback type was provided." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ▶ | elsif( $what ne 'add' && $what ne 'remove' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$what ne "add" and $what ne "remove"
MC/DC0%0/2
$what ne "add" and $what ne "remove"
$what ne "add"
$what ne "remove"
Truth table66%2/3
A and B
A= $what ne "add"B= $what ne "remove"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return( $self->error( "Callback type provided ($what) is unsupported. Use 'add' or 'remove'." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | elsif( scalar( @_ ) == 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return( $self->error( "No callback code was provided. Provide an anonymous subroutine, or reference to an existing subroutine." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ▶ | elsif( defined( $code ) && ref( $code ) ne 'CODE' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $code and ref $code ne "CODE"
MC/DC0%0/2
defined $code and ref $code ne "CODE"
defined $code
ref $code ne "CODE"
Truth table66%2/3
A and B
A= defined $codeB= ref $code ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return( $self->error( "Callback provided is not a code reference. Provide an anonymous subroutine, or reference to an existing subroutine." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | ▶ | if( !defined( $code ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # undef is passed as an argument, so we remove the callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | ▶ | if( scalar( @_ ) >= 2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # The array is not tied, so there is nothing to remove. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | my $tie = tied( $$self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | return(1) if( !$tie ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | my $rv = $tie->unset_callback( $what ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | ▶ | if( !$tie->has_callback ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | undef( $tie ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | untie( $$self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # Only 1 argument: get mode only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $tie = tied( $$self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | return if( !$tie ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return( $tie->get_callback( $what ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # $code is defined, so we have something to set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 5 | my $tie = tied( $$self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # Not tied yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 5 | ▶ | if( !$tie ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | ▶ | $tie = tie( $$self => 'Module::Generic::Scalar::Tie', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
tie($$self, 'Module::Generic::Scalar::Tie', {'data', $self, 'debug', $Module::Generic::Scalar::DEBUG, $what, $code}) || (return $self->error("Failed to tie scalar: $!"))
MC/DC0%0/1
tie($$self, 'Module::Generic::Scalar::Tie', {'data', $self, 'debug', $Module::Generic::Scalar::DEBUG, $what, $code}) || (return $self->error("Failed to tie scalar: $!"))
tie($$self, 'Module::Generic::Scalar::Tie', {'data', $self, 'debug', $Module::Generic::Scalar::DEBUG, $what, $code})
Truth table50%1/2
A
A= tie($$self, 'Module::Generic::Scalar::Tie', {'data', $self, 'debug', $Module::Generic::Scalar::DEBUG, $what, $code})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | data => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | debug => $DEBUG, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | $what => $code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | }) || return( $self->error( "Failed to tie scalar: $!" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | ▶ | $tie->set_callback( $what => $code ) || return( $self->error( "Failed to set callback for $what" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # Credits: John Gruber, Aristotle Pagaltzis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # https://gist.github.com/gruber/9f9e8650d68b13ce4d78 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | sub capitalise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
capitalise: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | my @small_words = qw( (?<!q&)a an and as at(?!&t) but by en for if in of on or the to v[.]? via vs[.]? ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | my $small_re = CORE::join( '|', @small_words ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | my $apos = qr/ (?: ['’] [[:lower:]]* )? /x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | my $copy = $$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | ▶ | return( $self->_new( $copy ) ) if( !CORE::defined( $copy ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | $copy =~ s{\A\s+}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | $copy =~ s{\s+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | ▶ | $copy = CORE::lc( $copy ) if( $copy !~ /[[:lower:]]/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | $copy =~ s{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | \b (_*) (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | ( (?<=[ ][/\\]) [[:alpha:]]+ [-_[:alpha:]/\\]+ | # file path or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | [-_[:alpha:]]+ [@.:] [-_[:alpha:]@.:/]+ $apos ) # URL, domain, or email | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ( (?i: $small_re ) $apos ) # or small word (case-insensitive) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ( [[:alpha:]] [[:lower:]'’()\[\]{}]* $apos ) # or word w/o internal caps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | ( [[:alpha:]] [[:alpha:]'’()\[\]{}]* $apos ) # or some other word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ) (_*) \b | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | }{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 18 | ▶ | $1 . ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | defined $2 ? $2 # preserve URL, domain, or email | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | : defined $3 ? "\L$3" # lowercase small word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | : defined $4 ? "\u\L$4" # capitalize word w/o internal caps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | : $5 # preserve other kinds of word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | ) . $6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | }xeg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # Exceptions for small words: capitalize at start and end of title | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | $copy =~ s{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ( \A [[:punct:]]* # start of title... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | | [:.;?!][ ]+ # or of subsentence... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | | [ ]['"“‘(\[][ ]* ) # or of inserted subphrase... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ( $small_re ) \b # ... followed by small word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | }{$1\u\L$2}xig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | $copy =~ s{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | \b ( $small_re ) # small word... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | (?= [[:punct:]]* \Z # ... at the end of the title... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | | ['"’”)\]] [ ] ) # ... or of an inserted subphrase? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | }{\u\L$1}xig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # Exceptions for small words in hyphenated compound words | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # e.g. "in-flight" -> In-Flight | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | $copy =~ s{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | \b | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | (?<! -) # Negative lookbehind for a hyphen; we don't want to match man-in-the-middle but do want (in-flight) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | ( $small_re ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | (?= -[[:alpha:]]+) # lookahead for "-someword" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | }{\u\L$1}xig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # e.g. "Stand-in" -> "Stand-In" (Stand is already capped at this point) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | $copy =~ s{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | \b | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | (?<!…) # Negative lookbehind for a hyphen; we don't want to match man-in-the-middle but do want (stand-in) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ( [[:alpha:]]+- ) # $1 = first word and hyphen, should already be properly capped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ( $small_re ) # ... followed by small word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | (?! - ) # Negative lookahead for another '-' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | }{$1\u$2}xig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | return( $self->_new( $copy ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 16 | ▶ | sub chomp { no warnings 'uninitialized'; return( CORE::chomp( ${$_[0]} ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
chomp: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 16 | ▶ | sub chop { no warnings 'uninitialized'; return( CORE::chop( ${$_[0]} ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
chop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | sub clone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 12 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 12 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | return( $self->_new( @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 11 | return( $self->_new( ${$self} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | sub crypt { return( __PACKAGE__->_new( CORE::crypt( ${$_[0]}, $_[1] ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
crypt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 737 | ▶ | sub defined { return( CORE::defined( ${$_[0]} ) ? 1 : 0 ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defined: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | sub empty { return( shift->reset( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
empty: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | sub error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=25 SCAR=63.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | my $addr = Scalar::Util::refaddr( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
builtin::refaddr($self) || $self
MC/DC0%0/2
builtin::refaddr($self) || $self
builtin::refaddr($self)
$self
Truth table0%0/3
A || B
A= builtin::refaddr($self)B= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 16 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # We absolutely need to have a per object repository, because our instances are scalar references; we cannot store an exception object within it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $repo = Module::Generic::Global->new( 'errors' => $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $args = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # We got an object as first argument. It could be a child from our exception package or from another package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # Either way, we use it as it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | if( ( Scalar::Util::blessed( $_[0] ) && $_[0]->isa( 'Module::Generic::Exception' ) ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
builtin::blessed($_[0]) and $_[0]->isa("Module::Generic::Exception") or builtin::blessed($_[0])
builtin::blessed($_[0]) and $_[0]->isa("Module::Generic::Exception")
MC/DC0%0/3
builtin::blessed($_[0]) and $_[0]->isa("Module::Generic::Exception") or builtin::blessed($_[0])
builtin::blessed($_[0])
$_[0]->isa("Module::Generic::Exception")
builtin::blessed($_[0])
Truth table0%0/5
A and B or C
A= builtin::blessed($_[0])B= $_[0]->isa("Module::Generic::Exception")C= builtin::blessed($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | Scalar::Util::blessed( $_[0] ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $o = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | elsif( ref( $_[0] ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $args = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | $args->{message} = CORE::join( '', CORE::map( ref( $_ ) eq 'CODE' ? $_->() : $_, @_ ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | $args->{class} //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"class"} //= ""
MC/DC0%0/1
$args->{"class"} //= ""
$args->{"class"}
Truth table0%0/2
A
A= $args->{"class"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | my $ex_class = CORE::length( $args->{class} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | ? $args->{class} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | : ( defined( ${"${class}\::EXCEPTION_CLASS"} ) && CORE::length( ${"${class}\::EXCEPTION_CLASS"} ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | ? ${"${class}\::EXCEPTION_CLASS"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined ${"${class}::EXCEPTION_CLASS";} and CORE::length ${"${class}::EXCEPTION_CLASS";}
MC/DC0%0/2
defined ${"${class}::EXCEPTION_CLASS";} and CORE::length ${"${class}::EXCEPTION_CLASS";}
defined ${"${class}::EXCEPTION_CLASS";}
CORE::length ${"${class}::EXCEPTION_CLASS";}
Truth table0%0/3
A and B
A= defined ${"${class}::EXCEPTION_CLASS";}B= CORE::length ${"${class}::EXCEPTION_CLASS";}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | : 'Module::Generic::Exception'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | unless( CORE::scalar( CORE::keys( %{"${ex_class}\::"} ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $pl = "use $ex_class;"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | local $SIG{__DIE__} = sub{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | eval( $pl ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # We have to die, because we have an error within another error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | die( "${class}\::error() is unable to load exception class \"$ex_class\": $@" ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $o = $ex_class->new( $args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $repo->set( $o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # $ERROR = $o; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | my $enc_str = eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | Encode::encode( 'UTF-8', "$o", Encode::FB_CROAK ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # Display warnings if warnings for this class is registered and enabled or if not registered | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | warn( $@ ? $o : $enc_str ) if( $self->_warnings_is_enabled( 'Module::Generic' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if( !$args->{no_return_null_object} && want( 'OBJECT' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $args->{"no_return_null_object"} and want("OBJECT")
MC/DC0%0/2
not $args->{"no_return_null_object"} and want("OBJECT")
not $args->{"no_return_null_object"}
want("OBJECT")
Truth table0%0/3
not(A) and B
A= not $args->{"no_return_null_object"}B= want("OBJECT")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | if( !$self->_is_class_loaded( 'Module::Generic::Null' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | eval( 'require Module::Generic::Null' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | die( "Unable to load module Module::Generic::Null" ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $null = Module::Generic::Null->new( $o, { debug => $DEBUG, has_error => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | rreturn( $null ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $o = $repo->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | if( !$o && want( 'OBJECT' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $o and want("OBJECT")
MC/DC0%0/2
not $o and want("OBJECT")
not $o
want("OBJECT")
Truth table0%0/3
not(A) and B
A= not $oB= want("OBJECT")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | if( !$self->_is_class_loaded( 'Module::Generic::Null' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | eval( 'require Module::Generic::Null' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | die( "Unable to load module Module::Generic::Null" ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my $null = Module::Generic::Null->new( $o, { debug => $DEBUG, wants => 'object' }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | rreturn( $null ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return( $o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | sub fc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fc: called CC=3 SCAR=20.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | my( $self, $str ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # CORE::fc was not available before perl v5.16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | ▶ | if( $] >= 5.016 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # We have to hide CORE::fc, otherwise perl v5.10.1 would throw an error: "CORE::fc is not a keyword" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | my $ref = CORE->can( 'fc' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | return( $ref->( $$self ) eq $ref->( $str ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | elsif( $str !~ /[^\x00-\x7f]/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | # Fast path: ASCII-only string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return( uc( $$self ) eq uc( $str ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | my $encode = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | my $string = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # Core module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | require Unicode::UCD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # Borrowed from Unicode::CaseFold | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my $out = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | foreach my $codepoint ( unpack( "U*", $string ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $mapping = Unicode::UCD::casefold( $codepoint ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my @cp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | if( !defined( $mapping ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | @cp = ( $codepoint ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | @cp = map( hex( $_ ), split( / /, $mapping->{full} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $out .= pack( "U*", @cp ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | return( $out ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | return( $encode->( $$self ) eq $encode->( $str ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | ▶ | sub hex { return( $_[0]->_number( CORE::hex( ${$_[0]} ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | sub index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 2 | my( $substr, $pos ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | return( $self->_number( CORE::index( ${$self}, $substr, $pos ) ) ) if( CORE::defined( $pos ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 2 | return( $self->_number( CORE::index( ${$self}, $substr ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 2 | ▶ | sub is_alpha { return( CORE::defined( ${$_[0]} ) && ${$_[0]} =~ /^[[:alpha:]]+$/ ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_alpha: called CC=2 SCAR=7.0
Pod
documented
Condition66%2/3
defined ${$_[0];} && ${$_[0];} =~ /^[[:alpha:]]+$/
MC/DC50%1/2
defined ${$_[0];} && ${$_[0];} =~ /^[[:alpha:]]+$/
defined ${$_[0];}
${$_[0];} =~ /^[[:alpha:]]+$/
Truth table66%2/3
A && B
A= defined ${$_[0];}B= ${$_[0];} =~ /^[[:alpha:]]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 1 | ▶ | sub is_alpha_numeric { return( CORE::defined( ${$_[0]} ) && ${$_[0]} =~ /^[[:alnum:]]+$/ ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_alpha_numeric: called CC=2 SCAR=7.6
Pod
documented
Condition33%1/3
defined ${$_[0];} && ${$_[0];} =~ /^[[:alnum:]]+$/
MC/DC0%0/2
defined ${$_[0];} && ${$_[0];} =~ /^[[:alnum:]]+$/
defined ${$_[0];}
${$_[0];} =~ /^[[:alnum:]]+$/
Truth table33%1/3
A && B
A= defined ${$_[0];}B= ${$_[0];} =~ /^[[:alnum:]]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | ▶ | sub is_empty { return( CORE::length( ${$_[0]} // '' ) == 0 ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_empty: called CC=2 SCAR=7.2
Pod
documented
Condition50%1/2
${$_[0];} // ""
MC/DC0%0/1
${$_[0];} // ""
${$_[0];}
Truth table50%1/2
A
A= ${$_[0];}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 1 | ▶ | sub is_lower { return( CORE::defined( ${$_[0]} ) && ${$_[0]} =~ /^[[:lower:]]+$/ ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_lower: called CC=2 SCAR=7.6
Pod
documented
Condition33%1/3
defined ${$_[0];} && ${$_[0];} =~ /^[[:lower:]]+$/
MC/DC0%0/2
defined ${$_[0];} && ${$_[0];} =~ /^[[:lower:]]+$/
defined ${$_[0];}
${$_[0];} =~ /^[[:lower:]]+$/
Truth table33%1/3
A && B
A= defined ${$_[0];}B= ${$_[0];} =~ /^[[:lower:]]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 1 | ▶ | sub is_numeric { return( Scalar::Util::looks_like_number( ${$_[0]} ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_numeric: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 1 | ▶ | sub is_upper { return( CORE::defined( ${$_[0]} ) && ${$_[0]} =~ /^[[:upper:]]+$/ ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_upper: called CC=2 SCAR=7.6
Pod
documented
Condition33%1/3
defined ${$_[0];} && ${$_[0];} =~ /^[[:upper:]]+$/
MC/DC0%0/2
defined ${$_[0];} && ${$_[0];} =~ /^[[:upper:]]+$/
defined ${$_[0];}
${$_[0];} =~ /^[[:upper:]]+$/
Truth table33%1/3
A && B
A= defined ${$_[0];}B= ${$_[0];} =~ /^[[:upper:]]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 2 | ▶ | sub join { return( __PACKAGE__->new( CORE::join( CORE::splice( @_, 1, 1 ), ${ shift( @_ ) }, @_ ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
join: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 16 | ▶ | sub lc { no warnings 'uninitialized'; return( __PACKAGE__->_new( CORE::lc( ${$_[0]} ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
lc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 16 | ▶ | sub lcfirst { no warnings 'uninitialized'; return( __PACKAGE__->_new( CORE::lcfirst( ${$_[0]} ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
lcfirst: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 16 | ▶ | sub left { no warnings 'uninitialized'; return( $_[0]->_new( CORE::substr( ${$_[0]}, 0, CORE::int( $_[1] ) ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
left: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # in perl v5.10.1 or earlier, length(undef) returns 0 instead of undef, which is not what we want. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 16 | ▶ | sub length { no warnings 'uninitialized'; return( $_[0]->_number( defined( ${$_[0]} ) ? CORE::length( ${$_[0]} ) : undef ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
length: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | sub like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
like: called CC=10 SCAR=29.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 2 | my $str = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 2 | my @matches = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 2 | my @rv = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 16 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 2 | ▶ | $str = CORE::defined( $str ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
ref $str eq "Regexp" or ref $str eq "Regexp::Common"
MC/DC0%0/2
ref $str eq "Regexp" or ref $str eq "Regexp::Common"
ref $str eq "Regexp"
ref $str eq "Regexp::Common"
Truth table33%1/3
A or B
A= ref $str eq "Regexp"B= ref $str eq "Regexp::Common"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | ? ( ref( $str ) eq 'Regexp' || ref( $str ) eq 'Regexp::Common' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | ? $str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | : qr/(?:\Q$str\E)+/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | : qr/[[:blank:]\r\n]*/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 2 | @rv = $$self =~ /$str/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 2 | ▶ | if( scalar( @{^CAPTURE} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | for( my $i = 0; $i < scalar( @{^CAPTURE} ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | push( @matches, ${^CAPTURE}[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # For named captures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 2 | my $names = { %+ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 2 | ▶ | unless( want( 'OBJECT' ) || want( 'SCALAR' ) || want( 'LIST' ) || scalar( @matches ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition37%3/8
want("OBJECT") or want("SCALAR") or want("LIST") or scalar @matches
want("OBJECT") or want("SCALAR") or want("LIST")
want("OBJECT") or want("SCALAR")
MC/DC0%0/3
want("OBJECT") or want("SCALAR") or want("LIST") or scalar @matches
want("OBJECT")
want("SCALAR")
want("LIST")
Truth table25%1/4
A or B or C
A= want("OBJECT")B= want("SCALAR")C= want("LIST")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 2 | return( Module::Generic::RegexpCapture->new( result => \@rv, capture => \@matches, name => $names ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | sub lower { return( shift->lc ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lower: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | sub ltrim | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ltrim: called CC=4 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 2 | my $str = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 16 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 2 | ▶ | $str = CORE::defined( $str ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $str eq "Regexp" or ref $str eq "Regexp::Common"
MC/DC0%0/2
ref $str eq "Regexp" or ref $str eq "Regexp::Common"
ref $str eq "Regexp"
ref $str eq "Regexp::Common"
Truth table0%0/3
A or B
A= ref $str eq "Regexp"B= ref $str eq "Regexp::Common"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | ? ( ref( $str ) eq 'Regexp' || ref( $str ) eq 'Regexp::Common' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | ? $str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | : qr/(?:\Q$str\E)+/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | : qr/[[:blank:]\r\n]*/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 2 | $$self =~ s/^$str//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 2 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | sub match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match: called CC=12 SCAR=28.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 5 | my( $self, $re ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 5 | my @matches = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 5 | my @rv = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 16 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 5 | ▶ | $re = CORE::defined( $re ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
ref $re eq "Regexp" or ref $re eq "Regexp::Common"
MC/DC0%0/2
ref $re eq "Regexp" or ref $re eq "Regexp::Common"
ref $re eq "Regexp"
ref $re eq "Regexp::Common"
Truth table33%1/3
A or B
A= ref $re eq "Regexp"B= ref $re eq "Regexp::Common"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | ? ( ref( $re ) eq 'Regexp' || ref( $re ) eq 'Regexp::Common' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | ? $re | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | : qr/(?:\Q$re\E)+/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | : $re; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 5 | @rv = $$self =~ $re; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | # For named captures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 5 | my $names = { %+ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # @{^CAPTURE} is only available with perl >= v5.26.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 5 | ▶ | if( $] >= 5.026 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 5 | ▶ | if( scalar( @{^CAPTURE} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 3 | ▶ | for( my $i = 0; $i < scalar( @{^CAPTURE} ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 7 | push( @matches, ${^CAPTURE}[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | for my $i ( 1 .. $#- ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | push( @matches, substr( $$self, $-[$i], $+[$i] - $-[$i] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 5 | ▶ | unless( want( 'OBJECT' ) || want( 'SCALAR' ) || want( 'LIST' ) || scalar( @matches ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition37%3/8
want("OBJECT") or want("SCALAR") or want("LIST") or scalar @matches
want("OBJECT") or want("SCALAR") or want("LIST")
want("OBJECT") or want("SCALAR")
MC/DC0%0/3
want("OBJECT") or want("SCALAR") or want("LIST") or scalar @matches
want("OBJECT")
want("SCALAR")
want("LIST")
Truth table25%1/4
A or B or C
A= want("OBJECT")B= want("SCALAR")C= want("LIST")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 5 | return( Module::Generic::RegexpCapture->new( result => \@rv, capture => \@matches, name => $names ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | sub object { return( $_[0] ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | sub open | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 2 | ▶ | $self->_load_class( 'Module::Generic::Scalar::IO' ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 2 | ▶ | my $io = Module::Generic::Scalar::IO->new( $self, @_ ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'Module::Generic::Scalar::IO'->new($self, @_) || (return $self->pass_error('Module::Generic::Scalar::IO'->error))
MC/DC0%0/1
'Module::Generic::Scalar::IO'->new($self, @_) || (return $self->pass_error('Module::Generic::Scalar::IO'->error))
'Module::Generic::Scalar::IO'->new($self, @_)
Truth table50%1/2
A
A= 'Module::Generic::Scalar::IO'->new($self, @_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | return( $self->pass_error( Module::Generic::Scalar::IO->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 2 | return( $io ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1 | ▶ | sub ord { return( $_[0]->_number( CORE::ord( ${$_[0]} ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ord: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 1 | ▶ | sub pack { return( __PACKAGE__->_new( CORE::pack( $_[1], ${$_[0]} ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | sub pad | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pad: called CC=7 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 2 | my( $n, $str ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 2 | ▶ | $str //= ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$str //= " "
MC/DC0%0/1
$str //= " "
$str
Truth table50%1/2
A
A= $str
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 2 | ▶ | if( !CORE::length( $n ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | warn( "No number provided to pad the string object.\n" ) if( $self->_warnings_is_enabled( 'Module::Generic' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | elsif( $n !~ /^\-?\d+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | warn( "Number provided \"$n\" to pad string is not an integer.\n" ) if( $self->_warnings_is_enabled( 'Module::Generic' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | ▶ | if( $n < 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 1 | $$self .= ( "$str" x CORE::abs( $n ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 1 | CORE::substr( $$self, 0, 0 ) = ( "$str" x $n ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 2 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | sub pass_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pass_error: not called CC=24 SCAR=63.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | my $ex_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 16 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | my $repo = Module::Generic::Global->new( 'errors' => $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if( scalar( @_ ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # Either an hash defining a new error and this will be passed along to error(); or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | # an hash with a single property: { class => 'Some::ExceptionClass' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | if( CORE::scalar( @_ ) == 1 && CORE::ref( $_[0] ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
scalar @_ == 1 and ref $_[0] eq "HASH"
scalar @_ == 1
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= scalar @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | $opts = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | # $self->pass_error( $error_object, { class => 'Some::ExceptionClass' } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | if( CORE::scalar( @_ ) > 1 && CORE::ref( $_[-1] ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @_ > 1 and ref $_[-1] eq "HASH"
MC/DC0%0/2
scalar @_ > 1 and ref $_[-1] eq "HASH"
scalar @_ > 1
ref $_[-1] eq "HASH"
Truth table0%0/3
A and B
A= scalar @_ > 1B= ref $_[-1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | $opts = CORE::pop( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | $err = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # We set $ex_class only if the hash provided is a one-element hash and not an error-defining hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | $ex_class = CORE::delete( $opts->{class} ) if( CORE::scalar( CORE::keys( %$opts ) ) == 1 && [CORE::keys( %$opts )]->[0] eq 'class' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar keys %$opts == 1 and [keys %$opts]->[0] eq "class"
MC/DC0%0/2
scalar keys %$opts == 1 and [keys %$opts]->[0] eq "class"
scalar keys %$opts == 1
[keys %$opts]->[0] eq "class"
Truth table0%0/3
A and B
A= scalar keys %$opts == 1B= [keys %$opts]->[0] eq "class"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # called with no argument, most likely from the same class to pass on an error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # set up earlier by another method; or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # with an hash containing just one argument class => 'Some::ExceptionClass' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | if( !CORE::defined( $err ) && ( !CORE::scalar( @_ ) || CORE::defined( $ex_class ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
not defined $err and !scalar(@_) || defined $ex_class
not scalar @_ or defined $ex_class
MC/DC0%0/3
not defined $err and !scalar(@_) || defined $ex_class
not defined $err
not scalar @_
defined $ex_class
Truth table0%0/4
not(A) and not(B) or C
A= not defined $errB= not scalar @_C= defined $ex_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | my $error = $repo->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | if( !CORE::defined( $error ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | warn( "No error object provided and no previous error set either! It seems the previous method call returned a simple undef" ) if( warnings::enabled( 'Module::Generic' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | $err = ( CORE::defined( $ex_class ) ? bless( $error => $ex_class ) : $error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | ▶ | elsif( CORE::defined( $err ) && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
defined $err and builtin::blessed($err) and scalar @_ == 1 || scalar @_ == 2 && defined $ex_class
defined $err and builtin::blessed($err)
scalar @_ == 1 or scalar @_ == 2 and defined $ex_class
scalar @_ == 2 and defined $ex_class
MC/DC0%0/5
defined $err and builtin::blessed($err) and scalar @_ == 1 || scalar @_ == 2 && defined $ex_class
defined $err
builtin::blessed($err)
scalar @_ == 1
scalar @_ == 2
defined $ex_class
Truth table0%0/6
A and B and C or D and E
A= defined $errB= builtin::blessed($err)C= scalar @_ == 1D= scalar @_ == 2E= defined $ex_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | Scalar::Util::blessed( $err ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ( CORE::scalar( @_ ) == 1 || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | ( CORE::scalar( @_ ) == 2 && CORE::defined( $ex_class ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | my $o = ( CORE::defined( $ex_class ) ? bless( $err => $ex_class ) : $err ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | $repo->set( $o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # $ERROR = $o; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | # If the error provided is not an object, we call error to create one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | return( $self->error( @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | if( want( 'OBJECT' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | if( !$self->_is_class_loaded( 'Module::Generic::Null' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | eval( 'require Module::Generic::Null' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | die( "Unable to load module Module::Generic::Null" ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $null = Module::Generic::Null->new( $err, { has_error => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | rreturn( $null ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | sub pos { return( $_[0]->_number( @_ > 1 ? ( CORE::pos( ${$_[0]} ) = $_[1] ) : CORE::pos( ${$_[0]} ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pos: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | sub prepend { return( shift->substr( 0, 0, ( ( Scalar::Util::reftype( $_[0] ) // '' ) eq 'SCALAR' ? ${$_[0]} : $_[0] ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepend: called CC=3 SCAR=14.2
Pod
documented
Branch: 1 branch
Condition50%1/2
builtin::reftype($_[0]) // ""
MC/DC0%0/1
builtin::reftype($_[0]) // ""
builtin::reftype($_[0])
Truth table50%1/2
A
A= builtin::reftype($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 1 | ▶ | sub quotemeta { return( __PACKAGE__->_new( CORE::quotemeta( ${$_[0]} ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quotemeta: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 1 | ▶ | sub right { return( $_[0]->_new( CORE::substr( ${$_[0]}, ( CORE::int( $_[1] ) * -1 ) ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
right: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | sub replace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replace: called CC=12 SCAR=25.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 8 | my( $self, $re, $replacement ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # Only to test if this was a regular expression. If it was the array will contain successful match, other it will be empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # @rv will contain the regexp matches or the result of the eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 8 | my @matches = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 8 | my @rv = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 8 | ▶ | $re = CORE::defined( $re ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
ref $re eq "Regexp" or ref $re eq "Regexp::Common"
MC/DC50%1/2
ref $re eq "Regexp" or ref $re eq "Regexp::Common"
ref $re eq "Regexp"
ref $re eq "Regexp::Common"
Truth table66%2/3
A or B
A= ref $re eq "Regexp"B= ref $re eq "Regexp::Common"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | ? ( ref( $re ) eq 'Regexp' || ref( $re ) eq 'Regexp::Common' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ? $re | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | : qr/(?:\Q$re\E)+/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | : $re; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | # return( $$self =~ s/$re/$replacement/gs ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # For named captures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 8 | my $names = { %+ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | # @{^CAPTURE} is only available with perl >= v5.26.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 8 | ▶ | if( $] >= 5.026 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 8 | @rv = $$self =~ s/$re/$replacement/gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # Only available in perl >= v5.26.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 8 | ▶ | if( scalar( @{^CAPTURE} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 2 | ▶ | for( my $i = 0; $i < scalar( @{^CAPTURE} ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 2 | push( @matches, ${^CAPTURE}[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | @rv = $$self =~ s{$re} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | for my $i ( 1 .. $#- ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | push( @matches, substr( $$self, $-[$i], $+[$i] - $-[$i] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | $replacement; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | }ges; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 8 | ▶ | unless( want( 'OBJECT' ) || want( 'SCALAR' ) || want( 'LIST' ) || scalar( @matches ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition87%7/8
want("OBJECT") or want("SCALAR") or want("LIST") or scalar @matches
want("OBJECT") or want("SCALAR") or want("LIST")
want("OBJECT") or want("SCALAR")
MC/DC66%2/3
want("OBJECT") or want("SCALAR") or want("LIST") or scalar @matches
want("OBJECT")
want("SCALAR")
want("LIST")
Truth table75%3/4
A or B or C
A= want("OBJECT")B= want("SCALAR")C= want("LIST")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 4 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 4 | return( Module::Generic::RegexpCapture->new( result => \@rv, capture => \@matches, name => $names ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 4 | ▶ | sub reset { ${$_[0]} = ''; return( $_[0] ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 1 | ▶ | sub reverse { return( __PACKAGE__->_new( CORE::scalar( CORE::reverse( ${$_[0]} ) ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reverse: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | sub rindex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rindex: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 2 | my( $substr, $pos ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 2 | ▶ | return( $self->_number( CORE::rindex( ${$self}, $substr, $pos ) ) ) if( CORE::defined( $pos ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 1 | return( $self->_number( CORE::rindex( ${$self}, $substr ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | sub rtrim | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rtrim: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 2 | my $str = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 2 | ▶ | $str = CORE::defined( $str ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
ref $str eq "Regexp" or ref $str eq "Regexp::Common"
MC/DC0%0/2
ref $str eq "Regexp" or ref $str eq "Regexp::Common"
ref $str eq "Regexp"
ref $str eq "Regexp::Common"
Truth table33%1/3
A or B
A= ref $str eq "Regexp"B= ref $str eq "Regexp::Common"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | ? ( ref( $str ) eq 'Regexp' || ref( $str ) eq 'Regexp::Common' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | ? $str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | : qr/(?:\Q$str\E)+/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | : qr/[[:blank:]\r\n]*/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 2 | $$self =~ s/${str}$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 2 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 116 | ▶ | sub scalar { return( shift->as_string ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scalar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | sub set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 45 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=7 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 45 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 45 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 45 | my $init; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 45 | ▶ | my $type = Scalar::Util::reftype( $_[0] ) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::reftype($_[0]) // ""
MC/DC0%0/1
builtin::reftype($_[0]) // ""
builtin::reftype($_[0])
Truth table50%1/2
A
A= builtin::reftype($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 45 | ▶ | if( $type eq 'SCALAR' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | $init = ${$_[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | elsif( $type eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | $init = CORE::join( '', @{$_[0]} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | elsif( ref( $_[0] ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | ▶ | warn( "I do not know what to do with \"", $_[0], "\" (", overload::StrVal( $_[0] ), ")\n" ) if( $self->_warnings_is_enabled( 'Module::Generic' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 45 | $init = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 45 | $$self = $init; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 45 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | sub split | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split: called CC=12 SCAR=33.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 7 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 7 | my( $expr, $limit ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 7 | ▶ | if( !scalar( @_ ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | ▶ | CORE::warn( "No argument was provided to split string in Module::Generic::Scalar::split\n" ) if( $self->_warnings_is_enabled( 'Module::Generic' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | # NOTE: As per perlfunc: "If omitted, PATTERN defaults to a single space, " ", triggering the previously described *awk* emulation." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | $expr = ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 7 | ▶ | unless( ref( $expr ) eq 'Regexp' || ref( $expr ) eq 'Regexp::Common' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $expr eq "Regexp" or ref $expr eq "Regexp::Common"
MC/DC0%0/2
ref $expr eq "Regexp" or ref $expr eq "Regexp::Common"
ref $expr eq "Regexp"
ref $expr eq "Regexp::Common"
Truth table33%1/3
A or B
A= ref $expr eq "Regexp"B= ref $expr eq "Regexp::Common"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | ▶ | if( ref( $expr ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | CORE::warn( "Expression provided is a reference of type '", ref( $expr ), "', but I was expecting either a regular expression or a simple string.\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | $expr = qr/\Q$expr\E/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 7 | my $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 7 | ▶ | $limit = "$limit" if( CORE::defined( $limit ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 7 | ▶ | if( CORE::defined( $limit ) && $limit =~ /^\d+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $limit and $limit =~ /^\d+$/
MC/DC0%0/2
defined $limit and $limit =~ /^\d+$/
defined $limit
$limit =~ /^\d+$/
Truth table33%1/3
A and B
A= defined $limitB= $limit =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | $ref = [ CORE::split( $expr, $$self, $limit ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 7 | $ref = [ CORE::split( $expr, $$self ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 7 | ▶ | if( Wanted::want( 'OBJECT' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
Wanted::want("OBJECT") or Wanted::want("SCALAR")
MC/DC100%2/2
Wanted::want("OBJECT") or Wanted::want("SCALAR")
Wanted::want("OBJECT")
Wanted::want("SCALAR")
Truth table100%3/3
A or B
A= Wanted::want("OBJECT")B= Wanted::want("SCALAR")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | Wanted::want( 'SCALAR' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 5 | rreturn( $self->_array( $ref ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | elsif( Wanted::want( 'LIST' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 2 | rreturn( @$ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 1 | ▶ | sub sprintf { return( __PACKAGE__->_new( CORE::sprintf( ${$_[0]}, @_[1..$#_] ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sprintf: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | sub substr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
substr: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 5 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 5 | my( $offset, $length, $replacement ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 5 | ▶ | return( __PACKAGE__->_new( CORE::substr( ${$self}, $offset, $length, $replacement ) ) ) if( CORE::defined( $length ) && CORE::defined( $replacement ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $length and defined $replacement
MC/DC50%1/2
defined $length and defined $replacement
defined $length
defined $replacement
Truth table66%2/3
A and B
A= defined $lengthB= defined $replacement
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 2 | ▶ | return( __PACKAGE__->_new( CORE::substr( ${$self}, $offset, $length ) ) ) if( CORE::defined( $length ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | return( __PACKAGE__->_new( CORE::substr( ${$self}, $offset ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | # The 3 dash here are just so my editor does not get confused with colouring | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | sub tr ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tr: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 1 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 1 | my( $search, $replace, $opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 1 | ▶ | $opts //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts //= ""
MC/DC0%0/1
$opts //= ""
$opts
Truth table50%1/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 1 | eval( "\$\$self =~ CORE::tr/$search/$replace/$opts" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 1 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | sub trim | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 3 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 3 | my $str = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 3 | ▶ | $str = CORE::defined( $str ) ? CORE::quotemeta( $str ) : qr/[[:blank:]\r\n]*/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 3 | $$self =~ s/^$str|$str$//gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 3 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 3 | ▶ | sub uc { return( __PACKAGE__->_new( CORE::uc( ${$_[0]} ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 1 | ▶ | sub ucfirst { return( __PACKAGE__->_new( CORE::ucfirst( ${$_[0]} ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ucfirst: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | sub undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undef: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 2 | $$self = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 2 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | sub unpack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=5 SCAR=17.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 5 | my( $self, $tmpl ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 5 | my $ref = [CORE::unpack( $tmpl, $$self )]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 5 | ▶ | if( Wanted::want( 'OBJECT' ) || Wanted::want( 'ARRAY' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
Wanted::want("OBJECT") or Wanted::want("ARRAY")
MC/DC100%2/2
Wanted::want("OBJECT") or Wanted::want("ARRAY")
Wanted::want("OBJECT")
Wanted::want("ARRAY")
Truth table100%3/3
A or B
A= Wanted::want("OBJECT")B= Wanted::want("ARRAY")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 3 | rreturn( $self->_array( $ref ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | elsif( Wanted::want( 'LIST' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 2 | rreturn( @$ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # In scalar context, return the first element, as per the original unpack behaviour | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | elsif( Wanted::want( 'SCALAR' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | rreturn( $ref->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | sub upper { return( shift->uc ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upper: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | sub _array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_array: called CC=6 SCAR=25.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 8 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 8 | my $arr = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 8 | ▶ | if( !defined( $arr ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | if( Wanted::want( 'OBJECT' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # We might have need to specify, because I found a race condition where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | # even though the context is object, once in Null, the context became 'code' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | ▶ | $self->_load_class( 'Module::Generic::Null' ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | return( Module::Generic::Null->new( wants => 'OBJECT' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 8 | ▶ | return( $arr ) if( ( Scalar::Util::reftype( $arr ) // '' ) ne 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($arr) // ""
MC/DC0%0/1
builtin::reftype($arr) // ""
builtin::reftype($arr)
Truth table50%1/2
A
A= builtin::reftype($arr)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 8 | return( Module::Generic::Array->new( $arr ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | sub _is_class_loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_class_loaded: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 2 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 2 | my $class = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 2 | ( my $pm = $class ) =~ s{::}{/}gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 2 | $pm .= '.pm'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 2 | ▶ | return(1) if( CORE::exists( $INC{ $pm } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 1 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | sub _load_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_class: called CC=10 SCAR=25.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 2 | my $class = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 2 | ▶ | die( "No class was provided to load." ) if( !$class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 2 | my $args = [@_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 2 | my $is_loaded = $self->_is_class_loaded( $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 2 | ▶ | if( $is_loaded ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 1 | ▶ | if( CORE::scalar( @$args ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | my $pl = "$class->import(" . ( CORE::scalar( @$args ) ? "'" . CORE::join( "', '", @$args ) . "'" : '' ) . ");"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | eval( $pl ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | return( $self->error( "Error importing class $class: $@" ) ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 1 | return( $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 1 | ▶ | local $SIG{__DIE__} = sub{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | # Load the module with thread safety | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 1 | ▶ | my $key = HAS_THREADS ? CORE::join( ';', $class, threads->tid() ) : $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 1 | my $repo = Module::Generic::Global->new( 'loaded_classes' => CORE::ref( $self ), key => $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 1 | my $pl = "require $class;"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 1 | eval( $pl ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 1 | ▶ | return( $self->error( "Unable to load package ${class}: $@\nCode executed was:\n${pl}" ) ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 1 | ▶ | $pl = "$class->import(" . ( CORE::scalar( @$args ) ? "'" . CORE::join( "', '", @$args ) . "'" : '' ) . ");"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 1 | eval( $pl ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 1 | ▶ | return( $self->error( "Error importing class $class: $@" ) ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 1 | $repo->set(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 1 | return( $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | sub _number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 31 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_number: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 31 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 31 | my $num = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 31 | ▶ | if( !defined( $num ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 1 | ▶ | if( Wanted::want( 'OBJECT' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | # We might have need to specify, because I found a race condition where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | # even though the context is object, once in Null, the context became 'code' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | ▶ | $self->_load_class( 'Module::Generic::Null' ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | return( Module::Generic::Null->new( wants => 'OBJECT' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 30 | ▶ | return( $num ) if( !CORE::length( $num ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 30 | return( Module::Generic::Number->new( $num ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 33 | ▶ | sub _new { return( shift->Module::Generic::Scalar::new( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | sub _warnings_is_enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_warnings_is_enabled: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | # I hate dying, but here this is a show-stopper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | die( "Object provided is undef!\n" ) if( @_ && !defined( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and not defined $_[0]
MC/DC0%0/2
@_ and not defined $_[0]
@_
not defined $_[0]
Truth table0%0/3
A and not(B)
A= @_B= not defined $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | my $obj = @_ ? shift( @_ ) : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | ▶ | return(0) if( !$self->_warnings_is_registered( $obj ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | ▶ | return( warnings::enabled( ref( $obj ) || $obj ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $obj || $obj
MC/DC0%0/2
ref $obj || $obj
ref $obj
$obj
Truth table0%0/3
A || B
A= ref $objB= $obj
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | sub _warnings_is_registered | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_warnings_is_registered: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | # I hate dying, but here this is a show-stopper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | ▶ | die( "Object provided is undef!\n" ) if( @_ && !defined( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and not defined $_[0]
MC/DC0%0/2
@_ and not defined $_[0]
@_
not defined $_[0]
Truth table0%0/3
A and not(B)
A= @_B= not defined $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | my $obj = @_ ? shift( @_ ) : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | ▶ | return(1) if( defined( $warnings::Bits{ ref( $obj ) || $obj } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $obj || $obj
MC/DC0%0/2
ref $obj || $obj
ref $obj
$obj
Truth table0%0/3
A || B
A= ref $objB= $obj
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | sub DESTROY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 2713 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | # <https://perldoc.perl.org/perlobj#Destructors> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 2713 | CORE::local( $., $@, $!, $^E, $? ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 2713 | ▶ | CORE::return if( &_in_global_destruction() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 2713 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 2713 | ▶ | CORE::return if( !CORE::defined( $self ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 2713 | ▶ | if( my $obj = Module::Generic::Global->new( 'errors' => $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 2713 | $obj->remove; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | # For non-object context, we need to call cleanup to ensure there is no leftover | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | # We cannot cleanup here the 'loaded_classes', because we need the class that is cached to build the key, and we do not have it at this very moment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | sub FREEZE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FREEZE: called CC=5 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 11 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 11 | ▶ | my $serialiser = CORE::shift( @_ ) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ // ""
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 11 | ▶ | my $class = CORE::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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | # Return an array reference rather than a list so this works with Sereal and CBOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | # On or before Sereal version 4.023, Sereal did not support multiple values returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 11 | ▶ | if( $serialiser eq 'Sereal' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 4 | require Sereal::Encoder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 4 | require version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 4 | ▶ | if( version->parse( Sereal::Encoder->VERSION ) <= version->parse( '4.023' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | CORE::return( [$class, $$self] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | # But Storable want a list with the first element being the serialised element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 11 | CORE::return( $$self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 7 | ▶ | sub STORABLE_freeze { CORE::return( CORE::shift->FREEZE( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 7 | ▶ | sub STORABLE_thaw { CORE::return( CORE::shift->THAW( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | sub THAW | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
THAW: called CC=5 SCAR=16.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 11 | my( $self, undef, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 11 | my( $class, $str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 11 | ▶ | if( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1
ref $args[0] eq "ARRAY"
Truth table33%1/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | ( $class, $str ) = @{$args[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 11 | ▶ | $class = CORE::ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table66%2/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 11 | $str = CORE::shift( @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 11 | my $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | # Storable pattern requires to modify the object it created rather than returning a new one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 11 | ▶ | if( CORE::ref( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 7 | $$self = $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 7 | $new = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 4 | $new = CORE::return( $class->new( $str ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 7 | CORE::return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 1 | ▶ | sub TO_JSON { CORE::return( ${$_[0]} ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | # NOTE: Module::Generic::RegexpCapture package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | Module::Generic::RegexpCapture; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 16 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 16 | ▶ | use vars qw( $ERROR $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 16 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 1 | ▶ | '""' => sub{ $_[0]->matched }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 6 | ▶ | '0+' => sub{ $_[0]->matched }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 16 | fallback => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 16 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 16 | our $ERROR = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 16 | our $VERSION = 'v0.1.1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 11 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 11 | $self->{capture} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 11 | $self->{name} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 11 | $self->{result} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 11 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 11 | return( $self->SUPER::init( @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 14 | ▶ | sub capture { return( shift->_set_get_array_as_object( 'capture', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
capture: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | sub matched | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
matched: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 9 | my $res = shift->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | # There may be one entry of empty value when there is no match, so we check for length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 9 | ▶ | return( $res->length->scalar ) if( $res->length && length( $res->get(0) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$res->length and length $res->get(0)
MC/DC50%1/2
$res->length and length $res->get(0)
$res->length
length $res->get(0)
Truth table66%2/3
A and B
A= $res->lengthB= length $res->get(0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 2 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 17 | ▶ | sub name { return( shift->_set_get_hash_as_object( 'name', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 21 | ▶ | sub result { return( shift->_set_get_array_as_object( 'result', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | sub FREEZE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FREEZE: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | ▶ | my $serialiser = CORE::shift( @_ ) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ // ""
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | my $class = CORE::ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | my %hash = %$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | # Return an array reference rather than a list so this works with Sereal and CBOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | # On or before Sereal version 4.023, Sereal did not support multiple values returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | ▶ | CORE::return( [$class, \%hash] ) if( $serialiser eq 'Sereal' && Sereal::Encoder->VERSION <= version->parse( '4.023' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
MC/DC0%0/2
$serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
$serialiser eq "Sereal"
"Sereal::Encoder"->VERSION <= "version"->parse("4.023")
Truth table0%0/3
A and B
A= $serialiser eq "Sereal"B= "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | # But Storable want a list with the first element being the serialised element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | CORE::return( $class, \%hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | ▶ | sub STORABLE_freeze { return( shift->FREEZE( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | ▶ | sub STORABLE_thaw { return( shift->THAW( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | # NOTE: CBOR will call the THAW method with the stored classname as first argument, the constant string CBOR as second argument, and all values returned by FREEZE as remaining arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | # NOTE: Storable calls it with a blessed object it created followed with $cloning and any other arguments initially provided by STORABLE_freeze | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | sub THAW | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
THAW: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | # STORABLE_thaw would issue $cloning as the 2nd argument, while CBOR would issue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | # 'CBOR' as the second value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | my( $self, undef, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | ▶ | my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1
ref $args[0] eq "ARRAY"
Truth table0%0/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | ▶ | my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref and ref $ref eq "ARRAY"
ref $self or $self
MC/DC0%0/3
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref
ref $ref eq "ARRAY"
scalar @$ref > 1
MC/DC0%0/2
ref $self or $self
ref $self
$self
Truth table0%0/4
A and B and C
A= defined $refB= ref $ref eq "ARRAY"C= scalar @$ref > 1
Truth table0%0/3
A or B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | ▶ | my $hash = CORE::ref( $ref ) eq 'ARRAY' ? CORE::shift( @$ref ) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | my $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | # Storable pattern requires to modify the object it created rather than returning a new one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | ▶ | if( CORE::ref( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | foreach( CORE::keys( %$hash ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | $self->{ $_ } = CORE::delete( $hash->{ $_ } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | $new = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | $new = CORE::bless( $hash => $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | CORE::return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | # NOTE: Module::Generic::Scalar::Tie class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 16 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | Module::Generic::Scalar::Tie; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 16 | ▶ | use vars qw( $LOCK ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 16 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 16 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 16 | ▶ | use constant HAS_THREADS => $Config{useithreads}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 16 | ▶ | use constant IN_THREAD => ( $Config{useithreads} && threads->tid != 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
Condition33%1/3
$Module::Generic::Scalar::Tie::Config{'useithreads'} && 'threads'->tid != 0
MC/DC0%0/2
$Module::Generic::Scalar::Tie::Config{'useithreads'} && 'threads'->tid != 0
$Module::Generic::Scalar::Tie::Config{'useithreads'}
'threads'->tid != 0
Truth table33%1/3
A && B
A= $Module::Generic::Scalar::Tie::Config{'useithreads'}B= 'threads'->tid != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 16 | if( HAS_THREADS ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | require threads; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | require threads::shared; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | threads->import(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | threads::shared->import(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | my $lock :shared; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | $LOCK = \$lock; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | ▶ | our $dummy_callback = sub{1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | sub TIESCALAR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIESCALAR: called CC=19 SCAR=45.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 1 | my( $class, $opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 1 | ▶ | $opts //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts //= {}
MC/DC0%0/1
$opts //= {}
$opts
Truth table50%1/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 1 | ▶ | if( ( Scalar::Util::reftype( $opts ) // '' ) ne 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($opts) // ""
MC/DC0%0/1
builtin::reftype($opts) // ""
builtin::reftype($opts)
Truth table50%1/2
A
A= builtin::reftype($opts)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | warn( "Options provided (", overload::StrVal( $opts ), ") is not an hash reference\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 1 | ▶ | $opts->{data} //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{"data"} //= ""
MC/DC0%0/1
$opts->{"data"} //= ""
$opts->{"data"}
Truth table50%1/2
A
A= $opts->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 1 | ▶ | $opts->{debug} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{"debug"} //= 0
MC/DC0%0/1
$opts->{"debug"} //= 0
$opts->{"debug"}
Truth table50%1/2
A
A= $opts->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 1 | ▶ | if( CORE::length( $opts->{add} ) && ref( $opts->{add} ) ne 'CODE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $opts->{"add"} and ref $opts->{"add"} ne "CODE"
MC/DC0%0/2
length $opts->{"add"} and ref $opts->{"add"} ne "CODE"
length $opts->{"add"}
ref $opts->{"add"} ne "CODE"
Truth table33%1/3
A and B
A= length $opts->{"add"}B= ref $opts->{"add"} ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | ▶ | warnings::warn( "Code provided for the scalar add callback is not a code reference.\n" ) if( warnings::enabled( 'Module::Generic::Scalar' ) || $opts->{debug} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
warnings::enabled("Module::Generic::Scalar") or $opts->{"debug"}
MC/DC0%0/2
warnings::enabled("Module::Generic::Scalar") or $opts->{"debug"}
warnings::enabled("Module::Generic::Scalar")
$opts->{"debug"}
Truth table0%0/3
A or B
A= warnings::enabled("Module::Generic::Scalar")B= $opts->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 1 | ▶ | if( CORE::length( $opts->{remove} ) && ref( $opts->{remove} ) ne 'CODE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $opts->{"remove"} and ref $opts->{"remove"} ne "CODE"
MC/DC0%0/2
length $opts->{"remove"} and ref $opts->{"remove"} ne "CODE"
length $opts->{"remove"}
ref $opts->{"remove"} ne "CODE"
Truth table33%1/3
A and B
A= length $opts->{"remove"}B= ref $opts->{"remove"} ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | ▶ | warnings::warn( "Code provided for the scalar remove callback is not a code reference.\n" ) if( warnings::enabled( 'Module::Generic::Scalar' ) || $opts->{debug} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
warnings::enabled("Module::Generic::Scalar") or $opts->{"debug"}
MC/DC0%0/2
warnings::enabled("Module::Generic::Scalar") or $opts->{"debug"}
warnings::enabled("Module::Generic::Scalar")
$opts->{"debug"}
Truth table0%0/3
A or B
A= warnings::enabled("Module::Generic::Scalar")B= $opts->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 1 | ▶ | my $data = ( ( Scalar::Util::reftype( $opts->{data} ) // '' ) eq 'SCALAR' ? \"${$opts->{data}}" : \undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($opts->{"data"}) // ""
MC/DC0%0/1
builtin::reftype($opts->{"data"}) // ""
builtin::reftype($opts->{"data"})
Truth table50%1/2
A
A= builtin::reftype($opts->{"data"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 1 | if( HAS_THREADS ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | threads::shared::share( $data ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | my $ref = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | callback_add => $opts->{add}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | callback_remove => $opts->{remove}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | debug => $opts->{debug}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | ▶ | print( STDERR ( ref( $class ) || $class ), "::TIESCALAR: Using ", CORE::length( ${$ref->{data}} ), " bytes of data in scalar vs ", CORE::length( ${$opts->{data}} ), " bytes received via opts->data.\n" ) if( $ref->{debug} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 1 | ▶ | return( bless( $ref => ( 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | sub FETCH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 19 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 19 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 19 | lock( $LOCK ) if( IN_THREAD ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 19 | return( ${$self->{data}} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | sub STORE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=13 SCAR=34.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 5 | my( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 5 | my $index = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 5 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | # New value is smaller than our current, so this is a removal. It could be partial or total | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 5 | ▶ | if( CORE::length( "$value" ) < CORE::length( ${$self->{data}} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 2 | ▶ | my $cb = $self->{callback_remove} || $dummy_callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'callback_remove'} || $Module::Generic::Scalar::Tie::dummy_callback
MC/DC0%0/2
$self->{'callback_remove'} || $Module::Generic::Scalar::Tie::dummy_callback
$self->{'callback_remove'}
$Module::Generic::Scalar::Tie::dummy_callback
Truth table33%1/3
A || B
A= $self->{'callback_remove'}B= $Module::Generic::Scalar::Tie::dummy_callback
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 2 | ▶ | if( !$cb ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | ▶ | warnings::warn( "No callback remove found. This should not happen.\n" ) if( warnings::enabled( 'Module::Generic::Scalar' ) || $self->{debug} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
warnings::enabled("Module::Generic::Scalar") or $self->{"debug"}
MC/DC0%0/2
warnings::enabled("Module::Generic::Scalar") or $self->{"debug"}
warnings::enabled("Module::Generic::Scalar")
$self->{"debug"}
Truth table0%0/3
A or B
A= warnings::enabled("Module::Generic::Scalar")B= $self->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | $rv = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 2 | $rv = $cb->({ type => 'remove', removed => \"${$self->{data}}", added => \$value }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 3 | ▶ | my $cb = $self->{callback_add} || $dummy_callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'callback_add'} || $Module::Generic::Scalar::Tie::dummy_callback
MC/DC0%0/2
$self->{'callback_add'} || $Module::Generic::Scalar::Tie::dummy_callback
$self->{'callback_add'}
$Module::Generic::Scalar::Tie::dummy_callback
Truth table33%1/3
A || B
A= $self->{'callback_add'}B= $Module::Generic::Scalar::Tie::dummy_callback
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 3 | ▶ | if( !$cb ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | ▶ | warnings::warn( "No callback add found. This should not happen.\n" ) if( warnings::enabled( 'Module::Generic::Scalar' ) || $self->{debug} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
warnings::enabled("Module::Generic::Scalar") or $self->{"debug"}
MC/DC0%0/2
warnings::enabled("Module::Generic::Scalar") or $self->{"debug"}
warnings::enabled("Module::Generic::Scalar")
$self->{"debug"}
Truth table0%0/3
A or B
A= warnings::enabled("Module::Generic::Scalar")B= $self->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | $rv = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 3 | $rv = $cb->({ type => 'add', added => \$value }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | ▶ | print( STDERR ref( $self ), "::STORE: adding ", CORE::length( "$value" ), " bytes of data ($value) at position $index with current data of ", CORE::length( ${$self->{data}} ), " bytes (", ${$self->{data}}, ") -> callback returned ", ( defined( $rv ) ? 'true' : 'undef' ), "\n" ) if( $self->{debug} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 5 | ▶ | return if( !defined( $rv ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 3 | lock( $LOCK ) if( IN_THREAD ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 3 | ${$self->{data}} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | sub has_callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_callback: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 2 | ▶ | return(1) if( ref( $self->{callback_add} ) eq 'CODE' || ref( $self->{callback_remove} ) eq 'CODE' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $self->{"callback_add"} eq "CODE" or ref $self->{"callback_remove"} eq "CODE"
MC/DC50%1/2
ref $self->{"callback_add"} eq "CODE" or ref $self->{"callback_remove"} eq "CODE"
ref $self->{"callback_add"} eq "CODE"
ref $self->{"callback_remove"} eq "CODE"
Truth table66%2/3
A or B
A= ref $self->{"callback_add"} eq "CODE"B= ref $self->{"callback_remove"} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 1 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | sub set_callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_callback: called CC=6 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 4 | my( $self, $what, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 4 | ▶ | if( !defined( $what ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | warn( "No callback type was provided. Use \"add\" or \"remove\".\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | ▶ | elsif( $what ne 'add' && $what ne 'remove' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$what ne "add" and $what ne "remove"
MC/DC0%0/2
$what ne "add" and $what ne "remove"
$what ne "add"
$what ne "remove"
Truth table66%2/3
A and B
A= $what ne "add"B= $what ne "remove"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | warn( "Unknown callback type was provided: '$what'. Use \"add\" or \"remove\".\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | elsif( !defined( $code ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | warn( "No callback anonymous subroutine or subroutine reference was provided.\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | elsif( ref( $code ) ne 'CODE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | warn( "Callback provided (", overload::StrVal( $code ), ") is not a code reference.\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 4 | lock( $LOCK ) if( IN_THREAD ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 4 | $self->{ "callback_${what}" } = $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 4 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | sub unset_callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unset_callback: called CC=4 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 2 | my( $self, $what ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 2 | ▶ | if( !defined( $what ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | warn( "No callback type was provided. Use \"add\" or \"remove\".\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | ▶ | elsif( $what ne 'add' && $what ne 'remove' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$what ne "add" and $what ne "remove"
MC/DC0%0/2
$what ne "add" and $what ne "remove"
$what ne "add"
$what ne "remove"
Truth table66%2/3
A and B
A= $what ne "add"B= $what ne "remove"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 0 | warn( "Unknown callback type was provided: '$what'. Use \"add\" or \"remove\".\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 2 | lock( $LOCK ) if( IN_THREAD ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 2 | $self->{ "callback_${what}" } = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 2 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||