| 1 | ## no critic: Modules::ProhibitAutomaticExportation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## no critic: BuiltinFunctions::RequireBlockGrep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## no critic: ValuesAndExpressions::ProhibitCommaSeparatedStatements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Data::Dump::Color; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use strict 'subs', 'vars'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use subs qq(dump); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use vars qw(@EXPORT @EXPORT_OK $VERSION $DEBUG); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | *import = \&Exporter::import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | @EXPORT = qw(dd ddx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | @EXPORT_OK = qw(dump pp dumpf quote); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | our $DATE = '2025-02-21'; # DATE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | our $DIST = 'Data-Dump-Color'; # DIST | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | our $VERSION = '0.251'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | $DEBUG = $ENV{DEBUG}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use overload (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | use vars qw(%seen %refcnt @fixup @cfixup %require $TRY_BASE64 @FILTERS $INDENT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | use vars qw($COLOR $COLOR_THEME $INDEX $LENTHRESHOLD); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | require # hide from cpanspec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | Win32::Console::ANSI if $^O =~ /Win/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | my $lan_available; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | require Scalar::Util::LooksLikeNumber; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | *looks_like_number = \&Scalar::Util::LooksLikeNumber::looks_like_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | $lan_available = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | *looks_like_number = \&Scalar::Util::looks_like_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | $TRY_BASE64 = 50 unless defined $TRY_BASE64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | $INDENT = " " unless defined $INDENT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | ▶ | $INDEX = 1 unless defined $INDEX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | ▶ | $LENTHRESHOLD = 500 unless defined $LENTHRESHOLD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | $COLOR = (defined $ENV{NO_COLOR} ? 0 : undef) // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | ▶ | $ENV{COLOR} // (-t STDOUT) // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition37%3/8
(((defined $ENV{"NO_COLOR"} ? 0 : undef) // $ENV{"COLOR"}) // -t STDOUT) // 1
((defined $ENV{"NO_COLOR"} ? 0 : undef) // $ENV{"COLOR"}) // -t STDOUT
(defined $ENV{"NO_COLOR"} ? 0 : undef) // $ENV{"COLOR"}
MC/DC0%0/3
(((defined $ENV{"NO_COLOR"} ? 0 : undef) // $ENV{"COLOR"}) // -t STDOUT) // 1
(defined $ENV{"NO_COLOR"} ? 0 : undef)
$ENV{"COLOR"}
-t STDOUT
Truth table25%1/4
A // B // C
A= (defined $ENV{"NO_COLOR"} ? 0 : undef)B= $ENV{"COLOR"}C= -t STDOUT
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | $COLOR_THEME = $ENV{DATA_DUMP_COLOR_THEME} // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | ▶ | (($ENV{TERM} // "") =~ /256/ ? 'Default256' : 'Default16'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$ENV{"DATA_DUMP_COLOR_THEME"} // (($ENV{"TERM"} // "") =~ /256/ ? "Default256" : "Default16")
$ENV{"TERM"} // ""
MC/DC0%0/1
$ENV{"DATA_DUMP_COLOR_THEME"} // (($ENV{"TERM"} // "") =~ /256/ ? "Default256" : "Default16")
$ENV{"DATA_DUMP_COLOR_THEME"}
Truth table50%1/2
A
A= $ENV{"DATA_DUMP_COLOR_THEME"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | our $ct_obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # from List::Util::PP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 59 | ▶ | sub max { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 59 | ▶ | return undef unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 59 | my $max = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | $_ > $max and $max = $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 59 | ▶ | foreach @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 59 | return $max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub _get_color_theme_obj { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_color_theme_obj: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | require Module::Load::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | Module::Load::Util::instantiate_class_with_optional_args( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | {ns_prefixes=>['ColorTheme::Data::Dump::Color','ColorTheme','']}, $COLOR_THEME); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 256 | ▶ | sub _col { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_col: called CC=5 SCAR=28.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 256 | require ColorThemeUtil::ANSI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 256 | my ($item, $str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 256 | ▶ | return $str unless $COLOR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | local $ct_obj = _get_color_theme_obj() unless defined $ct_obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $ansi = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $item = $ct_obj->get_item_color($item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if (defined $item) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $ansi = ColorThemeUtil::ANSI::item_color_to_ansi($item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if (length $ansi) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $ansi . $str . "\e[0m"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | sub dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: called CC=20 SCAR=31.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 8 | local %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 8 | local %refcnt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 8 | local %require; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | local @fixup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 8 | local @cfixup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 8 | ▶ | local $ct_obj = _get_color_theme_obj() if $COLOR && !(defined $ct_obj); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Data::Dump::Color::COLOR and not defined $Data::Dump::Color::ct_obj
MC/DC0%0/2
$Data::Dump::Color::COLOR and not defined $Data::Dump::Color::ct_obj
$Data::Dump::Color::COLOR
not defined $Data::Dump::Color::ct_obj
Truth table33%1/3
A and not(B)
A= $Data::Dump::Color::COLORB= not defined $Data::Dump::Color::ct_obj
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 8 | ▶ | require Data::Dump::FilterContext if @FILTERS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 8 | my $name = "var"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 8 | my @dump; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | my @cdump; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 8 | for my $v (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 8 | my ($val, $cval) = _dump($v, $name, [], tied($v)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 8 | push(@dump , [$name, $val]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | push(@cdump, [$name, $cval]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 8 | $name++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 8 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 8 | my $cout = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 8 | ▶ | if (%require) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | for (sort keys %require) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $out .= "require $_;\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $cout .= _col(keyword=>"require")." "._col(symbol=>$_).";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 8 | ▶ | if (%refcnt) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # output all those with refcounts first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | for my $i (0..$#dump) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | my $name = $dump[ $i][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | my $cname = $cdump[$i][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | ▶ | if ($refcnt{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | $out .= "my \$$name = $dump[$i][1];\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | $cout .= _col(keyword=>"my")." "._col(symbol=>"\$$cname")." = $cdump[$i][1];\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | undef $dump[ $i][1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | undef $cdump[$i][1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | for my $i (0..$#fixup) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | $out .= "$fixup[$i];\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | $cout .= "$cfixup[$i];\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 8 | my $paren = (@dump != 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 8 | ▶ | $out .= "(" if $paren; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 8 | ▶ | $cout .= "(" if $paren; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | my ($f, $cf) = format_list($paren, undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | [0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 8 | ▶ | [map {defined($_->[1]) ? $_->[1] : "\$".$_->[0]} @dump ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 8 | ▶ | [map {defined($_->[1]) ? $_->[1] : "\$".$_->[0]} @cdump], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | \@_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 8 | $out .= $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 8 | $cout .= $cf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 8 | ▶ | $out .= ")" if $paren; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 8 | ▶ | $cout .= ")" if $paren; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 8 | ▶ | if (%refcnt || %require) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
%Data::Dump::Color::refcnt or %Data::Dump::Color::require
MC/DC50%1/2
%Data::Dump::Color::refcnt or %Data::Dump::Color::require
%Data::Dump::Color::refcnt
%Data::Dump::Color::require
Truth table66%2/3
A or B
A= %Data::Dump::Color::refcntB= %Data::Dump::Color::require
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | $out .= ";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | $cout .= ";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | $out =~ s/^/$INDENT/gm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | $cout =~ s/^/$INDENT/gm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | $out = "do {\n$out}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | $cout = _col(keyword=>"do")." {\n$cout}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 8 | ▶ | print STDERR "$cout\n" unless defined wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | $cout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | *pp = \&dump; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | sub dd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dd: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | print dump(@_), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | ▶ | sub ddx { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ddx: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | my(undef, $file, $line) = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | $file =~ s,.*[\\/],,; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | my $out = dump(@_) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | $out =~ s/^/# /gm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | $out = _col(linum=>"$file:$line: ") . $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | print $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub dumpf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dumpf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | require Data::Dump::Filtered; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | goto &Data::Dump::Filtered::dump_filtered; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # return two result: (uncolored dump, colored dump) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | sub _dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 80 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dump: called CC=109 SCAR=70.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 80 | my $ref = ref $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 80 | ▶ | my $rval = $ref ? $_[0] : \$_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 80 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # compared to Data::Dump, each @$idx element is also a [uncolored,colored] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # instead of just a scalar. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 80 | my($name, $idx, $dont_remember, $pclass, $pidx) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 80 | my($class, $type, $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 80 | my $strval = overload::StrVal($rval); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # Parse $strval without using regexps, in order not to clobber $1, $2,... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 80 | ▶ | if ((my $i = rindex($strval, "=")) >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | $class = substr($strval, 0, $i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | $strval = substr($strval, $i+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 80 | ▶ | if ((my $i = index($strval, "(0x")) >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 80 | $type = substr($strval, 0, $i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 80 | $id = substr($strval, $i + 2, -1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | die "Can't parse " . overload::StrVal($rval); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 80 | ▶ | if ($] < 5.008 && $type eq "SCALAR") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$] < "5.008" and $type eq "SCALAR"
MC/DC0%0/2
$] < "5.008" and $type eq "SCALAR"
$] < "5.008"
$type eq "SCALAR"
Truth table33%1/3
A and B
A= $] < "5.008"B= $type eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $type = "REF" if $ref eq "REF"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 80 | ▶ | warn "\$$name(@$idx) $class $type $id ($ref)" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 80 | my $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | my $cout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 80 | my $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 80 | my $hide_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 80 | ▶ | if (@FILTERS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $pself = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | ($pself, undef) = fullname("self", [@$idx[$pidx..(@$idx - 1)]]) if $pclass; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $ctx = Data::Dump::FilterContext->new($rval, $class, $type, $ref, $pclass, $pidx, $idx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my @bless; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | for my $filter (@FILTERS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if (my $f = $filter->($ctx, $rval)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | if (my $v = $f->{object}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | local @FILTERS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ($out, $cout) = _dump($v, $name, $idx, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $dont_remember++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if (defined(my $c = $f->{bless})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | push(@bless, $c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if (my $c = $f->{comment}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $comment = $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if (defined(my $c = $f->{dump})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $out = $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $cout = $c; # XXX where's the colored version? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $dont_remember++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if (my $h = $f->{hide_keys}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if (ref($h) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $hide_keys = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | for my $k (@$h) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | return (1, 1) if $k eq $_[0]; # XXX color? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | return (0, 0); # XXX color? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | push(@bless, "") if defined($out) && !@bless; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $out and not @bless
MC/DC0%0/2
defined $out and not @bless
defined $out
not @bless
Truth table0%0/3
A and not(B)
A= defined $outB= not @bless
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | if (@bless) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $class = shift(@bless); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | warn "More than one filter callback tried to bless object" if @bless; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 80 | ▶ | unless ($dont_remember) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 80 | ▶ | if (my $s = $seen{$id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | my($sname, $sidx) = @$s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | $refcnt{$sname}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | ▶ | my ($sref, $csref) = fullname($sname, $sidx, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ref && $type eq 'SCALAR'
MC/DC0%0/2
$ref && $type eq 'SCALAR'
$ref
$type eq 'SCALAR'
Truth table33%1/3
A && B
A= $refB= $type eq 'SCALAR'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | ($ref && $type eq "SCALAR")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | ▶ | warn "SEEN: [\$$name(@$idx)] => [\$$sname(@$sidx)] ($ref,$sref)" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | ▶ | return ($sref, $csref) unless $sname eq $name; # XXX color? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | $refcnt{$name}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | my ($fn, $cfn) = fullname($name, $idx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | push(@fixup , "$fn = $sref"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | push(@cfixup, "$cfn = $csref"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | ▶ | "do{my \$fix}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$idx and $idx->[-1] eq "\$"
MC/DC0%0/2
@$idx and $idx->[-1] eq "\$"
@$idx
$idx->[-1] eq "\$"
Truth table33%1/3
A and B
A= @$idxB= $idx->[-1] eq "\$"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | _col(keyword=>"do")."{"._col(keyword=>"my")." "._col(symbol=>"\$fix")."}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ) if @$idx && $idx->[-1] eq '$'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | my $str = squote($sref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | $str, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | _col(string => $str), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 79 | $seen{$id} = [$name, $idx]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 79 | ▶ | if ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | $pclass = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | $pidx = @$idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 79 | ▶ | if (defined $out) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # keep it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ▶ | elsif ($type eq "SCALAR" || $type eq "REF" || $type eq "REGEXP") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$type eq "SCALAR" or $type eq "REF" or $type eq "REGEXP"
$type eq "SCALAR" or $type eq "REF"
MC/DC66%2/3
$type eq "SCALAR" or $type eq "REF" or $type eq "REGEXP"
$type eq "SCALAR"
$type eq "REF"
$type eq "REGEXP"
Truth table75%3/4
A or B or C
A= $type eq "SCALAR"B= $type eq "REF"C= $type eq "REGEXP"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 62 | ▶ | if ($ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 3 | ▶ | if ($class && $class eq "Regexp") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class and $class eq "Regexp"
MC/DC0%0/2
$class and $class eq "Regexp"
$class
$class eq "Regexp"
Truth table66%2/3
A and B
A= $classB= $class eq "Regexp"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $v = "$rval"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $mod = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | if ($v =~ /^\(\?\^?([msix-]*):([\x00-\xFF]*)\)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $mod = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $v = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $mod =~ s/-.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $sep = '/'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $sep_count = ($v =~ tr/\///); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if ($sep_count) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # see if we can find a better one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | for ('|', ',', ':', '#') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $c = eval "\$v =~ tr/\Q$_\E//"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | #print "SEP $_ $c $sep_count\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | if ($c < $sep_count) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $sep = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $sep_count = $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | last if $sep_count == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $v =~ s/\Q$sep\E/\\$sep/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $out = "qr$sep$v$sep$mod"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $cout = _col('Regexp', $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | undef($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | ▶ | delete $seen{$id} if $type eq "SCALAR"; # will be seen again shortly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 3 | my ($val, $cval) = _dump($$rval, $name, [@$idx, ["\$","\$"]], 0, $pclass, $pidx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | ▶ | $out = $class ? "do{\\(my \$o = $val)}" : "\\$val"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 3 | ▶ | $cout = $class ? _col(keyword=>"do")."{\\("._col(keyword=>"my")." "._col(symbol=>"\$o")." = $cval)}" : "\\$cval"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 59 | ▶ | if (!defined $$rval) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $out = 'undef'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $cout = _col('undef', "undef"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | elsif (my $ntype = looks_like_number($$rval)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 16 | ▶ | if ($lan_available) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # ntype returns details of the nature of numeric value in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # scalar, including the ability to differentiate stringy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # number "123" vs 123. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 16 | ▶ | my $val = $ntype < 20 ? qq("$$rval") : $$rval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 16 | ▶ | my $col = $ntype =~ /^(5|13|8704)$/ ? "float":"number"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 16 | $out = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 16 | $cout = _col($col => $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $val = $$rval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $col = "number"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $out = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $cout = _col($col => $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 43 | $out = str($$rval); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 43 | $cout = _col(string => $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 59 | ▶ | if ($class && !@$idx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$class and not @$idx
MC/DC0%0/2
$class and not @$idx
$class
not @$idx
Truth table33%1/3
A and not(B)
A= $classB= not @$idx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # Top is an object, not a reference to one as perl needs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $refcnt{$name}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my ($obj, $cobj) = fullname($name, $idx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $cl = quote($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | push(@fixup , "bless \\$obj, $cl"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | push(@cfixup, _col(keyword => "bless")." \\$cobj, "._col(string=>$cl)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | elsif ($type eq "GLOB") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if ($ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | delete $seen{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my ($val, $cval) = _dump($$rval, $name, [@$idx, ["*","*"]], 0, $pclass, $pidx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $out = "\\$val"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $cout = "\\$cval"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | if ($out =~ /^\\\*Symbol::/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $require{Symbol}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $out = "Symbol::gensym()"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $cout = _col(glob => $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $val = "$$rval"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $out = "$$rval"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $cout = _col(glob => $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | for my $k (qw(SCALAR ARRAY HASH)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my $gval = *$$rval{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | next unless defined $gval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | next if $k eq "SCALAR" && ! defined $$gval; # always there | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$k eq "SCALAR" and not defined $$gval
MC/DC0%0/2
$k eq "SCALAR" and not defined $$gval
$k eq "SCALAR"
not defined $$gval
Truth table0%0/3
A and not(B)
A= $k eq "SCALAR"B= not defined $$gval
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $f = scalar @fixup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | push(@fixup, "RESERVED"); # overwritten after _dump() below | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $cgval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ($gval, $cgval) = _dump($gval, $name, [@$idx, ["*{$k}", "*{"._col(string=>$k)."}"]], 0, $pclass, $pidx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $refcnt{$name}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my ($gname, $cgname) = fullname($name, $idx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $fixup[ $f] = "$gname = $gval" ; #XXX indent $gval | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $cfixup[$f] = "$gname = $cgval"; #XXX indent $gval | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | elsif ($type eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 6 | my @vals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | my @cvals; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 6 | my $tied = tied_str(tied(@$rval)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 6 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 6 | for my $v (@$rval) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 10 | my ($d, $cd) = _dump($v, $name, [@$idx, ["[$i]","["._col(number=>$i)."]"]], $tied, $pclass, $pidx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 10 | push @vals , $d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 10 | push @cvals, $cd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 10 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 6 | my ($f, $cf) = format_list(1, $tied, [scalar(@$idx)], \@vals, \@cvals, $rval); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 6 | $out = "[$f]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 6 | $cout = "[$cf]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | elsif ($type eq "HASH") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 11 | my(@keys, @vals, @cvals, @origk, @origv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 11 | my $tied = tied_str(tied(%$rval)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # statistics to determine variation in key lengths | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 11 | my $kstat_max = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 11 | my $kstat_sum = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 11 | my $kstat_sum2 = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 11 | my @orig_keys = keys %$rval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 11 | ▶ | if ($hide_keys) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | @orig_keys = grep !$hide_keys->($_), @orig_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 11 | my $text_keys = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 11 | for (@orig_keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 12 | ▶ | $text_keys++, last unless /^[-+]?(?:0|[1-9]\d*)(?:\.\d+)?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 11 | ▶ | if ($text_keys) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 10 | @orig_keys = sort { lc($a) cmp lc($b) } @orig_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | @orig_keys = sort { $a <=> $b } @orig_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 11 | my $quote; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 11 | for my $key (@orig_keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 59 | ▶ | next if $key =~ /^-?[a-zA-Z_]\w*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | ▶ | next if $key =~ /^-?[1-9]\d{0,8}\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | $quote++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 11 | my @lenvlastline; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 11 | for my $key (@orig_keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 59 | my $val = \$rval->{$key}; # capture value before we modify $key | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 59 | push(@origk, $key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 59 | ▶ | $key = quote($key) if $quote; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 59 | ▶ | $kstat_max = length($key) if length($key) > $kstat_max; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 59 | $kstat_sum += length($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 59 | $kstat_sum2 += length($key)*length($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 59 | push(@keys, $key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 59 | my ($v, $cv) = _dump($$val, $name, [@$idx, ["{$key}","{"._col(string=>$key)."}"]], $tied, $pclass, $pidx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 59 | push(@vals , $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 59 | push(@cvals, $cv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 59 | push(@origv, $$val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 59 | my ($vlastline) = $v =~ /(.*)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | #say "DEBUG: v=<$v>, vlastline=<$vlastline>" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 59 | my $lenvlastline = length($vlastline); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 59 | push @lenvlastline, $lenvlastline; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | #$maxvlen += length($INDENT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | #say "maxvlen=$maxvlen"; #TMP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 11 | my $nl = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 11 | my $klen_pad = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 11 | my $tmp = "@keys @vals"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 11 | ▶ | if (length($tmp) > 60 || $tmp =~ /\n/ || $tied) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
length $tmp > 60 or $tmp =~ /\n/ or $tied
length $tmp > 60 or $tmp =~ /\n/
MC/DC0%0/3
length $tmp > 60 or $tmp =~ /\n/ or $tied
length $tmp > 60
$tmp =~ /\n/
$tied
Truth table25%1/4
A or B or C
A= length $tmp > 60B= $tmp =~ /\n/C= $tied
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 11 | $nl = "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | # Determine what padding to add | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 11 | ▶ | if ($kstat_max < 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | $klen_pad = $kstat_max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | elsif (@keys >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 10 | my $n = @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 10 | my $avg = $kstat_sum/$n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 10 | my $stddev = sqrt(($kstat_sum2 - $n * $avg * $avg) / ($n - 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # I am not actually very happy with this heuristics | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 10 | ▶ | if ($stddev / $kstat_max < 0.25) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 7 | $klen_pad = $kstat_max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 10 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | push(@keys, "__S"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | push(@vals, sprintf("%.2f (%d/%.1f/%.1f)", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | $stddev / $kstat_max, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | $kstat_max, $avg, $stddev)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | push(@cvals, sprintf("%.2f (%d/%.1f/%.1f)", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | $stddev / $kstat_max, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | $kstat_max, $avg, $stddev)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 11 | my $maxkvlen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 11 | for (0..$#keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 59 | my $klen = length($keys[$_]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 59 | ▶ | $klen = $klen_pad if $klen < $klen_pad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 59 | my $kvlen = $klen + $lenvlastline[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 59 | ▶ | $maxkvlen = $kvlen if $maxkvlen < $kvlen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 11 | ▶ | $maxkvlen = 80 if $maxkvlen > 80; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 11 | $out = "{$nl"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 11 | $cout = "{$nl"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 11 | ▶ | $out .= "$INDENT# $tied$nl" if $tied; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 11 | ▶ | $cout .= $INDENT._col(comment=>"# $tied").$nl if $tied; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 11 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 11 | my $idxwidth = length(~~@keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 11 | ▶ | while (@keys) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 59 | my $key = shift(@keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 59 | my $val = shift @vals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 59 | my $cval = shift @cvals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 59 | my $origk = shift @origk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 59 | my $origv = shift @origv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 59 | my $lenvlastline = shift @lenvlastline; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 59 | my $vmultiline = length($val) > $lenvlastline; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 59 | ▶ | my $vpad = $INDENT . (" " x ($klen_pad ? $klen_pad + 4 : 0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 59 | $val =~ s/\n/\n$vpad/gm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 59 | $cval =~ s/\n/\n$vpad/gm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 59 | ▶ | my $kpad = $nl ? $INDENT : " "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 59 | my $pad_len = ($klen_pad - length($key)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 59 | ▶ | if ($pad_len < 0) { $pad_len = 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 59 | ▶ | $key .= " " x $pad_len if $nl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 59 | ▶ | my $cpad = " " x max(0, $maxkvlen - ($vmultiline ? -6+length($vpad) : length($key)) - $lenvlastline); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | #say "DEBUG: key=<$key>, vpad=<$vpad>, val=<$val>, lenvlastline=<$lenvlastline>, cpad=<$cpad>" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 59 | my $visaid = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 59 | ▶ | $visaid .= sprintf("%s{%${idxwidth}i}", "." x @$idx, $i) if $INDEX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 59 | ▶ | $visaid .= " klen=".length($origk) if defined $origk && length($origk) >= $LENTHRESHOLD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $origk and length $origk >= $Data::Dump::Color::LENTHRESHOLD
MC/DC0%0/2
defined $origk and length $origk >= $Data::Dump::Color::LENTHRESHOLD
defined $origk
length $origk >= $Data::Dump::Color::LENTHRESHOLD
Truth table33%1/3
A and B
A= defined $origkB= length $origk >= $Data::Dump::Color::LENTHRESHOLD
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 59 | ▶ | $visaid .= " vlen=".length($origv) if defined $origv && length($origv) >= $LENTHRESHOLD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $origv and length $origv >= $Data::Dump::Color::LENTHRESHOLD
MC/DC0%0/2
defined $origv and length $origv >= $Data::Dump::Color::LENTHRESHOLD
defined $origv
length $origv >= $Data::Dump::Color::LENTHRESHOLD
Truth table33%1/3
A and B
A= defined $origvB= length $origv >= $Data::Dump::Color::LENTHRESHOLD
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 59 | ▶ | $out .= "$kpad$key => $val," . ($nl && length($visaid) ? " $cpad# $visaid" : "") . $nl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$nl and length $visaid
MC/DC0%0/2
$nl and length $visaid
$nl
length $visaid
Truth table33%1/3
A and B
A= $nlB= length $visaid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 59 | ▶ | $cout .= $kpad._col(key=>$key)." => $cval,".($nl && length($visaid) ? " $cpad"._col(comment => "# $visaid") : "") . $nl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$nl and length $visaid
MC/DC0%0/2
$nl and length $visaid
$nl
length $visaid
Truth table33%1/3
A and B
A= $nlB= length $visaid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 59 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 11 | ▶ | $out =~ s/,$/ / unless $nl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 11 | ▶ | $cout =~ s/,$/ / unless $nl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 11 | $out .= "}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 11 | $cout .= "}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | elsif ($type eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | $out = 'sub { ... }'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $cout = _col(keyword=>'sub').' { ... }'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | elsif ($type eq "VSTRING") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | $out = sprintf +($ref ? '\v%vd' : 'v%vd'), $$rval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | $cout = _col(string => $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | warn "Can't handle $type data"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $out = "'#$type#'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $cout = _col(comment => $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 79 | ▶ | if ($class && $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class and $ref
MC/DC50%1/2
$class and $ref
$class
$ref
Truth table66%2/3
A and B
A= $classB= $ref
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 1 | $cout = _col(keyword=>"bless")."($cout, " . _col(string => quote($class)) . ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 1 | $out = "bless($out, ".quote($class).")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 79 | ▶ | if ($comment) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | $comment =~ s/^/# /gm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | $comment .= "\n" unless $comment =~ /\n\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | $comment =~ s/^#[ \t]+\n/\n/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | $cout = _col(comment=>$comment).$out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $out = "$comment$out"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 79 | return ($out, $cout); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 17 | ▶ | sub tied_str { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tied_str: called CC=3 SCAR=16.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 17 | my $tied = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 17 | ▶ | if ($tied) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if (my $tied_ref = ref($tied)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $tied = "tied $tied_ref"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | $tied = "tied"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 17 | return $tied; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # return two result: (uncolored dump, colored dump) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | sub fullname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fullname: called CC=11 SCAR=32.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | my($name, $idx, $ref) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 2 | substr($name, 0, 0) = "\$"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 2 | my $cname = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 2 | my @i = @$idx; # need copy in order to not modify @$idx | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 2 | ▶ | if ($ref && @i && $i[0][0] eq "\$") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$ref and @i and $i[0][0] eq "\$"
$ref and @i
MC/DC0%0/3
$ref and @i and $i[0][0] eq "\$"
$ref
@i
$i[0][0] eq "\$"
Truth table25%1/4
A and B and C
A= $refB= @iC= $i[0][0] eq "\$"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | shift(@i); # remove one deref | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $ref = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 2 | ▶ | while (@i && $i[0][0] eq "\$") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@i and $i[0][0] eq "\$"
MC/DC0%0/2
@i and $i[0][0] eq "\$"
@i
$i[0][0] eq "\$"
Truth table33%1/3
A and B
A= @iB= $i[0][0] eq "\$"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | shift @i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | $name = "\$$name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $cname = _col(symbol=>$name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 2 | my $last_was_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 2 | for my $i (@i) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 2 | ▶ | if ($i->[0] eq "*" || $i->[0] eq "\$") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$i->[0] eq "*" or $i->[0] eq "\$"
MC/DC0%0/2
$i->[0] eq "*" or $i->[0] eq "\$"
$i->[0] eq "*"
$i->[0] eq "\$"
Truth table33%1/3
A or B
A= $i->[0] eq "*"B= $i->[0] eq "\$"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $last_was_index = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $name = "$i->[0]\{$name}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $cname = "$i->[1]\{$cname}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } elsif ($i->[0] =~ s/^\*//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $name .= $i->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $cname .= $i->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | $last_was_index++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 2 | $name .= "->"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 2 | $cname .= "->"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 2 | $name .= $i->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 2 | $cname .= $i->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 2 | ▶ | $name = "\\$name" if $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 2 | ($name, $cname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | # return two result: (uncolored dump, colored dump) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | sub format_list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 14 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_list: called CC=27 SCAR=51.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 14 | my $paren = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 14 | my $comment = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 14 | my $extra = shift; # [level, ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 14 | ▶ | my $indent_lim = $paren ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 14 | my @vals = @{ shift(@_) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 14 | my @cvals = @{ shift(@_) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 14 | my @orig = @{ shift(@_) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 14 | ▶ | if (@vals > 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # can we use range operator to shorten the list? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 1 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 1 | ▶ | while ($i < @vals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 4 | my $j = $i + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 4 | my $v = $vals[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 4 | ▶ | while ($j < @vals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | # XXX allow string increment too? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 3 | ▶ | if ($v eq "0" || $v =~ /^-?[1-9]\d{0,9}\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$v eq 0 or $v =~ /^-?[1-9]\d{0,9}\z/
MC/DC50%1/2
$v eq 0 or $v =~ /^-?[1-9]\d{0,9}\z/
$v eq 0
$v =~ /^-?[1-9]\d{0,9}\z/
Truth table66%2/3
A or B
A= $v eq 0B= $v =~ /^-?[1-9]\d{0,9}\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 1 | $v++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | elsif ($v =~ /^"([A-Za-z]{1,3}\d*)"\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $v = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | $v++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $v = qq("$v"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 1 | ▶ | last if $vals[$j] ne $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 4 | ▶ | if ($j - $i > 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | splice(@vals , $i, $j - $i, "$vals[$i] .. $vals[$j-1]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | splice(@cvals, $i, $j - $i, "$cvals[$i] .. $cvals[$j-1]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | splice(@orig , $i, $j - $i, [@orig[$i..$j-1]]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 4 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 14 | my $tmp = "@vals"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 14 | ▶ | if ($comment || (@vals > $indent_lim && (length($tmp) > 60 || $tmp =~ /\n/))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
$comment or @vals > $indent_lim and length $tmp > 60 || $tmp =~ /\n/
@vals > $indent_lim and length $tmp > 60 || $tmp =~ /\n/
length $tmp > 60 or $tmp =~ /\n/
MC/DC0%0/4
$comment or @vals > $indent_lim and length $tmp > 60 || $tmp =~ /\n/
$comment
@vals > $indent_lim
length $tmp > 60
$tmp =~ /\n/
Truth table40%2/5
A or B and C or D
A= $commentB= @vals > $indent_limC= length $tmp > 60D= $tmp =~ /\n/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $maxvlen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | for (@vals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my ($vfirstline) = /\A(.*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | my $lenvfirstline = length($vfirstline); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | $maxvlen = $lenvfirstline if $maxvlen < $lenvfirstline; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | $maxvlen = 80 if $maxvlen > 80; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $maxvlen += length($INDENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | my @res = ("\n", $comment ? "$INDENT# $comment\n" : ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | my @cres = ("\n", $comment ? $INDENT._col("# $comment")."\n" : ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my @elem = @vals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my @celem = @cvals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | for (@elem ) { s/^/$INDENT/gm; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | for (@celem) { s/^/$INDENT/gm; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $idxwidth = length(~~@elem); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | for my $i (0..$#elem) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my ($vlastline) = $elem[$i] =~ /(.*)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my $cpad = " " x max(0, $maxvlen - length($vlastline)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | my $visaid = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | $visaid .= sprintf("%s[%${idxwidth}i]", "." x $extra->[0], $i) if $INDEX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | $visaid .= " len=".length($orig[$i]) if defined $orig[$i] && length($orig[$i]) >= $LENTHRESHOLD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $orig[$i] and length $orig[$i] >= $Data::Dump::Color::LENTHRESHOLD
MC/DC0%0/2
defined $orig[$i] and length $orig[$i] >= $Data::Dump::Color::LENTHRESHOLD
defined $orig[$i]
length $orig[$i] >= $Data::Dump::Color::LENTHRESHOLD
Truth table0%0/3
A and B
A= defined $orig[$i]B= length $orig[$i] >= $Data::Dump::Color::LENTHRESHOLD
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | push @res , $elem[ $i], ",", (length($visaid) ? " $cpad# $visaid" : ""), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | push @cres, $celem[$i], ",", (length($visaid) ? " $cpad"._col(comment => "# $visaid") : ""), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | return (join("", @res), join("", @cres)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 14 | return (join(", ", @vals), join(", ", @cvals)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 43 | ▶ | sub str { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
str: called CC=15 SCAR=44.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 43 | ▶ | if (length($_[0]) > 20) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 3 | for ($_[0]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # Check for repeated string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 3 | ▶ | if (/^(.)\1\1\1/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # seems to be a repeating sequence, let's check if it really is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # without backtracking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | unless (/[^\Q$1\E]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | my $base = quote($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | my $repeat = length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | return "($base x $repeat)" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | # Length protection because the RE engine will blow the stack [RT#33520] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 3 | ▶ | if (length($_) < 16 * 1024 && /^(.{2,5}?)\1*\z/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $_ < 16384 and /^(.{2,5}?)\1*\z/s
MC/DC0%0/2
length $_ < 16384 and /^(.{2,5}?)\1*\z/s
length $_ < 16384
/^(.{2,5}?)\1*\z/s
Truth table33%1/3
A and B
A= length $_ < 16384B= /^(.{2,5}?)\1*\z/s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | my $base = quote($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my $repeat = length($_)/length($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | return "($base x $repeat)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 43 | local $_ = "e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 43 | ▶ | if (length($_) > 40 && !/\\x\{/ && length($_) > (length($_[0]) * 2)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
length $_ > 40 and not /\\x\{/ and length $_ > length($_[0]) * 2
length $_ > 40 and not /\\x\{/
MC/DC0%0/3
length $_ > 40 and not /\\x\{/ and length $_ > length($_[0]) * 2
length $_ > 40
not /\\x\{/
length $_ > length($_[0]) * 2
Truth table50%2/4
A and not(B) and C
A= length $_ > 40B= not /\\x\{/C= length $_ > length($_[0]) * 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # too much binary data, better to represent as a hex/base64 string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # Base64 is more compact than hex when string is longer than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # 17 bytes (not counting any require statement needed). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # But on the other hand, hex is much more readable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | if ($TRY_BASE64 && length($_[0]) > $TRY_BASE64 && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/12
$Data::Dump::Color::TRY_BASE64 and length $_[0] > $Data::Dump::Color::TRY_BASE64 and (defined &utf8::is_utf8 and not utf8::is_utf8($_[0])) and eval {
do {
require MIME::Base64
}
}
$Data::Dump::Color::TRY_BASE64 and length $_[0] > $Data::Dump::Color::TRY_BASE64 and (defined &utf8::is_utf8 and not utf8::is_utf8($_[0]))
$Data::Dump::Color::TRY_BASE64 and length $_[0] > $Data::Dump::Color::TRY_BASE64
defined &utf8::is_utf8 and not utf8::is_utf8($_[0])
MC/DC0%0/5
$Data::Dump::Color::TRY_BASE64 and length $_[0] > $Data::Dump::Color::TRY_BASE64 and (defined &utf8::is_utf8 and not utf8::is_utf8($_[0])) and eval {
do {
require MIME::Base64
}
}
$Data::Dump::Color::TRY_BASE64
length $_[0] > $Data::Dump::Color::TRY_BASE64
defined &utf8::is_utf8
not utf8::is_utf8($_[0])
eval {
do {
require MIME::Base64
}
}
Truth table0%0/6
A and B and C and not(D) and E
A= $Data::Dump::Color::TRY_BASE64B= length $_[0] > $Data::Dump::Color::TRY_BASE64C= defined &utf8::is_utf8D= not utf8::is_utf8($_[0])E= eval {
do {
require MIME::Base64
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | (defined &utf8::is_utf8 && !utf8::is_utf8($_[0])) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | eval { require MIME::Base64 }) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | $require{"MIME::Base64"}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | return "MIME::Base64::decode(\"" . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | MIME::Base64::encode($_[0],"") . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | "\")"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | return "pack(\"H*\",\"" . unpack("H*", $_[0]) . "\")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 43 | return $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 3 | my %esc = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | "\a" => "\\a", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | "\b" => "\\b", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | "\t" => "\\t", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | "\n" => "\\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | "\f" => "\\f", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | "\r" => "\\r", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | "\e" => "\\e", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # put a string value in double quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 45 | ▶ | sub quote { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote: called CC=2 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 45 | local($_) = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | # If there are many '"' we might want to use qq() instead | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 45 | s/([\\\"\@\$])/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 45 | ▶ | return qq("$_") unless /[^\040-\176]/; # fast exit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | s/([\a\b\t\n\f\r\e])/$esc{$1}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | # no need for 3 digits in escape for these | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | s/([\0-\037])(?!\d)/sprintf('\\%o',ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | s/([\0-\037\177-\377])/sprintf('\\x%02X',ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | s/([^\040-\176])/sprintf('\\x{%X}',ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | return qq("$_"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | # put a string value in single quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 1 | ▶ | sub squote { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
squote: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 1 | local($_) = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 1 | s/([\\'])/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 1 | return qq('$_'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | # ABSTRACT: Like Data::Dump, but with color | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||