| 1 | package Data::Printer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use Data::Printer::Object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use Data::Printer::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Data::Printer::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | our $VERSION = '1.002001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | my $rc_arguments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | my %arguments_for; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 10 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 10 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 10 | _initialize(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 10 | my $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 10 | ▶ | if (@_ > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 8 | ▶ | $args = @_ == 1 ? shift : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 8 | ▶ | Data::Printer::Common::_warn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 'Data::Printer can receive either a hash or a hash reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ) unless ref $args eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | $args = Data::Printer::Config::_expand_profile($args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 8 | ▶ | if exists $args->{profile}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # every time you load it, we override the version from *your* caller | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 10 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | $arguments_for{$caller} = $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 10 | my $use_prototypes = _find_option('use_prototypes', $args, $caller, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 10 | ▶ | my $exported = ($use_prototypes ? \&p : \&_p_without_prototypes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 10 | my $imported = _find_option('alias', $args, $caller, 'p'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 8 | ▶ | { no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 10 | *{"$caller\::$imported"} = $exported; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 10 | *{"$caller\::np"} = \&np; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 8 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=5 SCAR=19.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # potential race but worst case is we read it twice :) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 8 | ▶ | { no warnings 'redefine'; *_initialize = sub {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | my $rc_filename = Data::Printer::Config::_get_first_rc_file_available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | $rc_arguments = Data::Printer::Config::load_rc_file($rc_filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 8 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
exists $rc_arguments->{"_"}{"live_update"} and defined $rc_arguments->{"_"}{"live_update"} and $rc_arguments->{"_"}{"live_update"} =~ /\A\d+\z/ and $rc_arguments->{"_"}{"live_update"} > 0
exists $rc_arguments->{"_"}{"live_update"} and defined $rc_arguments->{"_"}{"live_update"} and $rc_arguments->{"_"}{"live_update"} =~ /\A\d+\z/
exists $rc_arguments->{"_"}{"live_update"} and defined $rc_arguments->{"_"}{"live_update"}
MC/DC0%0/4
exists $rc_arguments->{"_"}{"live_update"} and defined $rc_arguments->{"_"}{"live_update"} and $rc_arguments->{"_"}{"live_update"} =~ /\A\d+\z/ and $rc_arguments->{"_"}{"live_update"} > 0
exists $rc_arguments->{"_"}{"live_update"}
defined $rc_arguments->{"_"}{"live_update"}
$rc_arguments->{"_"}{"live_update"} =~ /\A\d+\z/
$rc_arguments->{"_"}{"live_update"} > 0
Truth table20%1/5
A and B and C and D
A= exists $rc_arguments->{"_"}{"live_update"}B= defined $rc_arguments->{"_"}{"live_update"}C= $rc_arguments->{"_"}{"live_update"} =~ /\A\d+\z/D= $rc_arguments->{"_"}{"live_update"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | exists $rc_arguments->{'_'}{live_update} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | && defined $rc_arguments->{'_'}{live_update} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | && $rc_arguments->{'_'}{live_update} =~ /\A\d+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | && $rc_arguments->{'_'}{live_update} > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $last_mod = (stat $rc_filename)[9]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | *_initialize = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | if (time - $now > $rc_arguments->{'_'}{live_update}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | my $new_last_mod = (stat $rc_filename)[9]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | if (defined $new_last_mod && $new_last_mod > $last_mod) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | $now = time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | $last_mod = $new_last_mod; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | $rc_arguments = Data::Printer::Config::load_rc_file($rc_filename); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | if (!exists $rc_arguments->{'_'}{live_update} || !$rc_arguments->{'_'}{live_update}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | *_initialize = sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 13 | ▶ | sub np (\[@$%&];%) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
np: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 13 | my (undef, %properties) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 13 | _initialize(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 13 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 13 | my $args_to_use = _fetch_args_with($caller, \%properties); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 13 | ▶ | return '' if $args_to_use->{quiet}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 13 | my $printer = Data::Printer::Object->new($args_to_use); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # force color level 0 on 'auto' colors: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 13 | ▶ | if ($printer->colored eq 'auto') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $printer->{_output_color_level} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 13 | my $ref = ref $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 13 | ▶ | if ($ref eq 'ARRAY' || $ref eq 'HASH' || ($ref eq 'REF' && ref ${$_[0]} eq 'REF')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$ref eq "ARRAY" or $ref eq "HASH" or $ref eq "REF" and ref ${$_[0];} eq "REF"
$ref eq "ARRAY" or $ref eq "HASH"
$ref eq "REF" and ref ${$_[0];} eq "REF"
MC/DC100%4/4
$ref eq "ARRAY" or $ref eq "HASH" or $ref eq "REF" and ref ${$_[0];} eq "REF"
$ref eq "ARRAY"
$ref eq "HASH"
$ref eq "REF"
ref ${$_[0];} eq "REF"
Truth table100%5/5
A or B or C and D
A= $ref eq "ARRAY"B= $ref eq "HASH"C= $ref eq "REF"D= ref ${$_[0];} eq "REF"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | $printer->{_refcount_base}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 13 | my $output = $printer->parse($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 13 | ▶ | if ($printer->caller_message_position eq 'after') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $output .= $printer->_write_label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 13 | $output = $printer->_write_label . $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 13 | return $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 44 | ▶ | sub p (\[@$%&];%) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
p: called CC=10 SCAR=23.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 44 | my (undef, %properties) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 44 | _initialize(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 44 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 44 | my $args_to_use = _fetch_args_with($caller, \%properties); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 44 | my $want_value = defined wantarray; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # return as quickly as possible under 'quiet'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 44 | ▶ | if ($args_to_use->{quiet}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # we avoid creating a Data::Printer::Object instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # to speed things up, since we don't do anything under 'quiet'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $return_type = Data::Printer::Common::_fetch_anyof( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | $args_to_use, 'return_value', 'pass', [qw(pass dump void)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return _handle_output(undef, undef, $want_value, $_[0], $return_type, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 44 | my $printer = Data::Printer::Object->new($args_to_use); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 44 | ▶ | if ($printer->colored eq 'auto' && $printer->return_value eq 'dump' && $want_value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$printer->colored eq "auto" and $printer->return_value eq "dump" and $want_value
$printer->colored eq "auto" and $printer->return_value eq "dump"
MC/DC0%0/3
$printer->colored eq "auto" and $printer->return_value eq "dump" and $want_value
$printer->colored eq "auto"
$printer->return_value eq "dump"
$want_value
Truth table25%1/4
A and B and C
A= $printer->colored eq "auto"B= $printer->return_value eq "dump"C= $want_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $printer->{_output_color_level} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 44 | my $ref = ref $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 44 | ▶ | if ($ref eq 'ARRAY' || $ref eq 'HASH' || ($ref eq 'REF' && ref ${$_[0]} eq 'REF')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$ref eq "ARRAY" or $ref eq "HASH" or $ref eq "REF" and ref ${$_[0];} eq "REF"
$ref eq "ARRAY" or $ref eq "HASH"
$ref eq "REF" and ref ${$_[0];} eq "REF"
MC/DC100%4/4
$ref eq "ARRAY" or $ref eq "HASH" or $ref eq "REF" and ref ${$_[0];} eq "REF"
$ref eq "ARRAY"
$ref eq "HASH"
$ref eq "REF"
ref ${$_[0];} eq "REF"
Truth table100%5/5
A or B or C and D
A= $ref eq "ARRAY"B= $ref eq "HASH"C= $ref eq "REF"D= ref ${$_[0];} eq "REF"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 7 | $printer->{_refcount_base}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 44 | my $output = $printer->parse($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 44 | ▶ | if ($printer->caller_message_position eq 'after') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | $output .= $printer->_write_label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 43 | $output = $printer->_write_label . $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 44 | return _handle_output($output, $printer->{output_handle}, $want_value, $_[0], $printer->return_value, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # This is a p() clone without prototypes. Just like regular Data::Dumper, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # this version expects a reference as its first argument. We make a single | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # exception for when we only get one argument, in which case we ref it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # for the user and keep going. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | ▶ | sub _p_without_prototypes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_p_without_prototypes: called CC=15 SCAR=30.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | my (undef, %properties) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 4 | my $item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | ▶ | if (!ref $_[0] && @_ == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $_[0] and @_ == 1
MC/DC50%1/2
not ref $_[0] and @_ == 1
not ref $_[0]
@_ == 1
Truth table66%2/3
not(A) and B
A= not ref $_[0]B= @_ == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | my $item_value = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | $item = \$item_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | _initialize(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 4 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 4 | my $args_to_use = _fetch_args_with($caller, \%properties); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | my $want_value = defined wantarray; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # return as quickly as possible under 'quiet'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | ▶ | if ($args_to_use->{quiet}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # we avoid creating a Data::Printer::Object instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # to speed things up, since we don't do anything under 'quiet'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $return_type = Data::Printer::Common::_fetch_anyof( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | $args_to_use, 'return_value', 'pass', [qw(pass dump void)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | return _handle_output(undef, undef, $want_value, $_[0], $return_type, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | my $printer = Data::Printer::Object->new($args_to_use); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 4 | ▶ | if ($printer->colored eq 'auto' && $printer->return_value eq 'dump' && $want_value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$printer->colored eq "auto" and $printer->return_value eq "dump" and $want_value
$printer->colored eq "auto" and $printer->return_value eq "dump"
MC/DC0%0/3
$printer->colored eq "auto" and $printer->return_value eq "dump" and $want_value
$printer->colored eq "auto"
$printer->return_value eq "dump"
$want_value
Truth table25%1/4
A and B and C
A= $printer->colored eq "auto"B= $printer->return_value eq "dump"C= $want_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $printer->{_output_color_level} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | ▶ | my $ref = ref( defined $item ? $item : $_[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 4 | ▶ | if ($ref eq 'ARRAY' || $ref eq 'HASH' || ($ref eq 'REF' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%6/9
$ref eq "ARRAY" or $ref eq "HASH" or $ref eq "REF" and ref(defined $item ? $item : ${$_[0];}) eq "REF"
$ref eq "ARRAY" or $ref eq "HASH"
$ref eq "REF" and ref(defined $item ? $item : ${$_[0];}) eq "REF"
MC/DC50%2/4
$ref eq "ARRAY" or $ref eq "HASH" or $ref eq "REF" and ref(defined $item ? $item : ${$_[0];}) eq "REF"
$ref eq "ARRAY"
$ref eq "HASH"
$ref eq "REF"
ref(defined $item ? $item : ${$_[0];}) eq "REF"
Truth table60%3/5
A or B or C and D
A= $ref eq "ARRAY"B= $ref eq "HASH"C= $ref eq "REF"D= ref(defined $item ? $item : ${$_[0];}) eq "REF"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | && ref(defined $item ? $item : ${$_[0]}) eq 'REF')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | $printer->{_refcount_base}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | ▶ | my $output = $printer->parse((defined $item ? $item : $_[0])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 4 | ▶ | if ($printer->caller_message_position eq 'after') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $output .= $printer->_write_label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 4 | $output = $printer->_write_label . $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 4 | return _handle_output($output, $printer->{output_handle}, $want_value, $_[0], $printer->return_value, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 48 | ▶ | sub _handle_output { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_output: called CC=11 SCAR=24.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 48 | my ($output, $out_handle, $wantarray, $data, $return_type, $quiet) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 48 | ▶ | if ($return_type eq 'pass') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 9 | ▶ | print { $out_handle } $output . "\n" unless $quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 9 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 9 | my $ref = Scalar::Util::blessed($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 9 | ▶ | return $data if defined $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 8 | $ref = Scalar::Util::reftype($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 8 | ▶ | if (!$ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | elsif ($ref eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | return @$data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | elsif ($ref eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | return %$data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 12 | elsif ( grep { $ref eq $_ } qw(REF SCALAR VSTRING) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | return $$data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ▶ | elsif ($return_type eq 'void' || !$wantarray) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$return_type eq "void" or not $wantarray
MC/DC100%2/2
$return_type eq "void" or not $wantarray
$return_type eq "void"
not $wantarray
Truth table100%3/3
A or not(B)
A= $return_type eq "void"B= not $wantarray
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 7 | ▶ | print { $out_handle} $output . "\n" unless $quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 32 | return $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 61 | ▶ | sub _fetch_args_with { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_args_with: called CC=6 SCAR=18.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 61 | my ($caller, $run_properties) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 61 | my $args_to_use = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 61 | ▶ | if (keys %$rc_arguments) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | $args_to_use = Data::Printer::Config::_merge_options( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 61 | $args_to_use, $rc_arguments->{'_'} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 61 | ▶ | if (exists $rc_arguments->{$caller}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | $args_to_use = Data::Printer::Config::_merge_options( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $args_to_use, $rc_arguments->{$caller} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 61 | ▶ | if ($arguments_for{$caller}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | $args_to_use = Data::Printer::Config::_merge_options( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 61 | $args_to_use, $arguments_for{$caller} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 61 | ▶ | if (keys %$run_properties) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | $run_properties = Data::Printer::Config::_expand_profile($run_properties) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 15 | ▶ | if exists $run_properties->{profile}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 15 | $args_to_use = Data::Printer::Config::_merge_options( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | $args_to_use, $run_properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 61 | return $args_to_use; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 20 | ▶ | sub _find_option { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_option: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 20 | my ($key, $args, $caller, $default) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 20 | my $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 20 | ▶ | if (exists $args->{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | $value = $args->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
exists $rc_arguments->{$caller} and exists $rc_arguments->{$caller}{$key}
MC/DC0%0/2
exists $rc_arguments->{$caller} and exists $rc_arguments->{$caller}{$key}
exists $rc_arguments->{$caller}
exists $rc_arguments->{$caller}{$key}
Truth table33%1/3
A and B
A= exists $rc_arguments->{$caller}B= exists $rc_arguments->{$caller}{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | exists $rc_arguments->{$caller} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | && exists $rc_arguments->{$caller}{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $value = $rc_arguments->{$caller}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | elsif (exists $rc_arguments->{'_'}{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $value = $rc_arguments->{'_'}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 18 | $value = $default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 20 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 8 | 'Marielle, presente.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||