| 1 | package Data::Printer::Profile::Dumper; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | sub profile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
profile: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | show_tainted => 0, | |||||||||||||||||||||||||||||||||||||||||
| 8 | show_unicode => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 9 | show_lvalue => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 10 | print_escapes => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 11 | scalar_quotes => q('), | ||||||||||||||||||||||||||||||||||||||||||
| 12 | escape_chars => 'none', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | string_max => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 14 | unicode_charnames => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | array_max => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 16 | index => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | hash_max => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 18 | hash_separator => ' => ', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | align_hash => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | sort_keys => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | quote_keys => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 22 | name => '$VAR1', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | arrows => 'first', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | return_value => 'dump', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | output => 'stderr', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | indent => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | show_readonly => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | show_tied => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | show_dualvar => 'off', | ||||||||||||||||||||||||||||||||||||||||||
| 30 | show_weak => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | show_refcount => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | show_memsize => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | separator => ',', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | end_separator => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | caller_info => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | colored => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | class_method => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # Data::Printer doesn't provide a way to directly | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # decorate filters, so we do it ourselves: | ||||||||||||||||||||||||||||||||||||||||||
| 40 | filters => [ | ||||||||||||||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||||||||||||||
| 42 | '-class' => \&_data_dumper_class_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 'SCALAR' => \&_data_dumper_scalar_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 'LVALUE' => \&_data_dumper_lvalue_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 'HASH' => \&_data_dumper_hash_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 'ARRAY' => \&_data_dumper_array_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 'CODE' => \&_data_dumper_code_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 'FORMAT' => \&_data_dumper_format_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 'GLOB' => \&_data_dumper_glob_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 'REF' => \&_data_dumper_ref_filter,, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 'Regexp' => \&_data_dumper_regexp_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 'VSTRING' => \&_data_dumper_vstring_filter, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | sub _data_dumper_regexp_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_regexp_filter: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | my ($re, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | my $v = "$re"; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | my $mod = ""; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | if ($v =~ /^\(\?\^?([msixpadlun-]*):([\x00-\xFF]*)\)\z/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | $mod = $1; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | $v = $2; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | $mod =~ s/-.*//; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | $v =~ s{/}{\\/}g; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | return _output_wrapper($ddp, $ddp->maybe_colorize("qr/$v/$mod", 'regex')); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | sub _data_dumper_glob_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_glob_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | my ($glob, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | my $ret = "$$glob"; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | $ret =~ s|\A\*main:|\*:|; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | $ret =~ s|\A\*|\\*{'|; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | $ret .= '\'}'; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | return _output_wrapper($ddp, $ddp->maybe_colorize($ret, 'glob')); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub _data_dumper_lvalue_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_lvalue_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | my (undef, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | Data::Printer::Common::_warn($ddp, 'cannot handle ref type 10'); | |||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | return _output_wrapper($ddp, ''); | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | sub _data_dumper_scalar_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_scalar_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 5 | my ($scalar, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | my $ret = Data::Printer::Filter::SCALAR::parse(@_); | |||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | return _output_wrapper($ddp, $ret); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | ▶ | sub _data_dumper_ref_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_ref_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | my ($scalar, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | $ddp->indent; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | my $ret = Data::Printer::Filter::REF::parse(@_); | |||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | $ret =~ s{\A[\\]+\s+}{\\}; # DDP's REF filter adds a space after refs. | |||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | $ddp->outdent; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | return _output_wrapper($ddp, $ret); | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | sub _data_dumper_vstring_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_vstring_filter: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | my ($scalar, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | my $ret = Data::Printer::Filter::VSTRING::parse(@_); | |||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | if ($] < 5.009 && substr($ret, 0, 7) eq 'VSTRING') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$] < "5.009" and substr($ret, 0, 7) eq "VSTRING"
MC/DC0%0/2
$] < "5.009" and substr($ret, 0, 7) eq "VSTRING"
$] < "5.009"
substr($ret, 0, 7) eq "VSTRING"
Truth table33%1/3
A and B
A= $] < "5.009"B= substr($ret, 0, 7) eq "VSTRING"
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $ret = $ddp->maybe_colorize('', 'vstring'); | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | return _output_wrapper($ddp, $ret); | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | sub _data_dumper_format_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_format_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | my (undef, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | Data::Printer::Common::_warn($ddp, 'cannot handle ref type 14'); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | return _output_wrapper($ddp, ''); | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | sub _data_dumper_code_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_code_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | my (undef, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | return _output_wrapper($ddp, $ddp->maybe_colorize('sub { "DUMMY" }', 'code')); | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | sub _data_dumper_array_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_array_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | my ($hashref, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | my $ret = Data::Printer::Filter::ARRAY::parse(@_); | |||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | return _output_wrapper($ddp, $ret); | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | sub _data_dumper_hash_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_hash_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | my ($hashref, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | my $ret = Data::Printer::Filter::HASH::parse(@_); | |||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | return _output_wrapper($ddp, $ret); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | sub _data_dumper_class_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_dumper_class_filter: called CC=6 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | my ($obj, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | my $reftype = Scalar::Util::reftype($obj); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | $reftype = 'Regexp' if $reftype eq 'REGEXP'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | my ($parse_prefix, $parse_suffix) = ('', ''); | |||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | ▶ | if ($reftype eq 'SCALAR' || $reftype eq 'REF' || $reftype eq 'VSTRING') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$reftype eq "SCALAR" or $reftype eq "REF" or $reftype eq "VSTRING"
$reftype eq "SCALAR" or $reftype eq "REF"
MC/DC0%0/3
$reftype eq "SCALAR" or $reftype eq "REF" or $reftype eq "VSTRING"
$reftype eq "SCALAR"
$reftype eq "REF"
$reftype eq "VSTRING"
Truth table25%1/4
A or B or C
A= $reftype eq "SCALAR"B= $reftype eq "REF"C= $reftype eq "VSTRING"
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | $parse_prefix = 'do{\(my $o = '; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | ▶ | $parse_prefix .= '\\' if $reftype eq 'REF'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | $parse_suffix = ')}'; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | $ddp->indent; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | my $ret = $ddp->maybe_colorize('bless( ' . $parse_prefix, 'method') | |||||||||||||||||||||||||||||||||||||||||
| 146 | . $ddp->parse_as($reftype, $obj) | ||||||||||||||||||||||||||||||||||||||||||
| 147 | . $ddp->maybe_colorize($parse_suffix, 'method') | ||||||||||||||||||||||||||||||||||||||||||
| 148 | . q|, '| . $ddp->maybe_colorize(ref($obj), 'class') . q|'| | ||||||||||||||||||||||||||||||||||||||||||
| 149 | . $ddp->maybe_colorize(' )', 'method') | ||||||||||||||||||||||||||||||||||||||||||
| 150 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | $ddp->outdent; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | return _output_wrapper($ddp, $ret); | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 17 | ▶ | sub _output_wrapper { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_output_wrapper: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 17 | my ($ddp, $output) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 17 | ▶ | if ($ddp->current_depth == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | $output = '$VAR1 = ' . $output . ';'; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 17 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 165 | __END__ | ||||||||||||||||||||||||||||||||||||||||||