| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Acme::CPANModules::DumpingDataForDebugging; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
459188
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
257
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
6
|
|
|
|
|
|
|
our $DATE = '2023-10-29'; # DATE |
|
7
|
|
|
|
|
|
|
our $DIST = 'Acme-CPANModules-DumpingDataForDebugging'; # DIST |
|
8
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $LIST = { |
|
11
|
|
|
|
|
|
|
summary => 'List of modules and tips when dumping data structures for debugging', |
|
12
|
|
|
|
|
|
|
description => <<'_', |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This list catalogs some of the modules you can you to dump your data structures |
|
15
|
|
|
|
|
|
|
for debugging purposes, so the modules will be judged mostly by the |
|
16
|
|
|
|
|
|
|
appropriateness of its output for human viewing (instead of other criteria like |
|
17
|
|
|
|
|
|
|
speed, footprint, etc). |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
_ |
|
20
|
|
|
|
|
|
|
entries => [ |
|
21
|
|
|
|
|
|
|
{ |
|
22
|
|
|
|
|
|
|
module=>'Data::Dumper', |
|
23
|
|
|
|
|
|
|
tags => ['perl'], |
|
24
|
|
|
|
|
|
|
description => <<'_', |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Everybody knows this module and it's core so sometimes it's the only appropriate |
|
27
|
|
|
|
|
|
|
choice. However, the default setting is not really optimized for viewing by |
|
28
|
|
|
|
|
|
|
human. I suggest you tweak these before dumping your data: |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
* Set $Data::Dumper::Useqq to 1. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
By default, quotes strings using single-quotes and does not |
|
33
|
|
|
|
|
|
|
quote things like "\n" and "\b" making it difficult to spot special characters. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
_ |
|
37
|
|
|
|
|
|
|
}, |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
{ |
|
40
|
|
|
|
|
|
|
module=>'Data::Dump', |
|
41
|
|
|
|
|
|
|
tags => ['perl'], |
|
42
|
|
|
|
|
|
|
description => <<'_', |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
A data dumper that produces nicer Perl code output, with features like vertical |
|
45
|
|
|
|
|
|
|
alignment of "=>" when dumping hashes, compacting sequences like 1,2,3,4,5,6 to |
|
46
|
|
|
|
|
|
|
1..6, compacting repeating characters in string like "ccccccccccccccccccccc" to |
|
47
|
|
|
|
|
|
|
("c" x 21), and so on. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
It tries harder to produce Perl code that generates the original data structure, |
|
50
|
|
|
|
|
|
|
particularly with circular references. But with interlinked references like |
|
51
|
|
|
|
|
|
|
trees, Data::Dumper might be more helpful in showing you which references get |
|
52
|
|
|
|
|
|
|
mentioned where. For example this data: |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$tree = {children=>[{children=>[{}]}, {children=>[]}]}; |
|
55
|
|
|
|
|
|
|
$tree->{children}[0]{parent}=$tree; |
|
56
|
|
|
|
|
|
|
$tree->{children}[1]{parent}=$tree; |
|
57
|
|
|
|
|
|
|
$tree->{children}[0]{children}[0]{parent} = $tree->{children}[0]; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Data::Dump will produce: |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
do { |
|
62
|
|
|
|
|
|
|
my $a = { |
|
63
|
|
|
|
|
|
|
children => [ |
|
64
|
|
|
|
|
|
|
{ children => [{ parent => 'fix' }], parent => 'fix' }, |
|
65
|
|
|
|
|
|
|
{ children => [], parent => 'fix' }, |
|
66
|
|
|
|
|
|
|
], |
|
67
|
|
|
|
|
|
|
}; |
|
68
|
|
|
|
|
|
|
$a->{children}[0]{children}[0]{parent} = $a->{children}[0]; |
|
69
|
|
|
|
|
|
|
$a->{children}[0]{parent} = $a; |
|
70
|
|
|
|
|
|
|
$a->{children}[1]{parent} = $a; |
|
71
|
|
|
|
|
|
|
$a; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
while Data::Dumper will produce: |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$VAR1 = { |
|
77
|
|
|
|
|
|
|
'children' => [ |
|
78
|
|
|
|
|
|
|
{ |
|
79
|
|
|
|
|
|
|
'children' => [ |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
|
|
|
|
|
|
'parent' => $VAR1->{'children'}[0] |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
], |
|
84
|
|
|
|
|
|
|
'parent' => $VAR1 |
|
85
|
|
|
|
|
|
|
}, |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
|
|
|
|
|
|
'parent' => $VAR1, |
|
88
|
|
|
|
|
|
|
'children' => [] |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
] |
|
91
|
|
|
|
|
|
|
}; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
_ |
|
94
|
|
|
|
|
|
|
}, |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
{ |
|
97
|
|
|
|
|
|
|
module=>'Data::Dump::Color', |
|
98
|
|
|
|
|
|
|
tags => ['perl'], |
|
99
|
|
|
|
|
|
|
description => <<'_', |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
A modification to Data::Dump which adds color (and color theme) support, as well |
|
102
|
|
|
|
|
|
|
as other visual aids like depth and array index/hash pair count indicator. It's |
|
103
|
|
|
|
|
|
|
usually my go-to module for debugging. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
_ |
|
106
|
|
|
|
|
|
|
}, |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
{ |
|
109
|
|
|
|
|
|
|
module=>'Data::Dumper::Compact', |
|
110
|
|
|
|
|
|
|
tags => ['perl'], |
|
111
|
|
|
|
|
|
|
description => <<'_', |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
A relatively recent module by MSTROUT. I will need to use this more to see if I |
|
114
|
|
|
|
|
|
|
really like the output, but so far I do. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
_ |
|
117
|
|
|
|
|
|
|
}, |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
{ |
|
120
|
|
|
|
|
|
|
module=>'XXX', |
|
121
|
|
|
|
|
|
|
tags => ['perl'], |
|
122
|
|
|
|
|
|
|
description => <<'_', |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
A nice little dumper module from the creator of YAML. Obviously, it uses YAML |
|
125
|
|
|
|
|
|
|
output by default but it's configurable to dump in other formats. For example: |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
PERL_XXX_DUMPER=Data::Dump::Color |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
It's main selling point is that the dumper function returns the original |
|
130
|
|
|
|
|
|
|
arguments so the dumping can be done in various places in code, making it more |
|
131
|
|
|
|
|
|
|
convenient. More (if not all) dumpers should do this too. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
_ |
|
134
|
|
|
|
|
|
|
}, |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
{ |
|
137
|
|
|
|
|
|
|
module=>'Data::Printer', |
|
138
|
|
|
|
|
|
|
tags => ['perlish'], |
|
139
|
|
|
|
|
|
|
description => <<'_', |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Favorites among many Perl programmers, it sports colors, array index indicator, |
|
142
|
|
|
|
|
|
|
as well as nice object dumper showing methods and inheritance information. It's |
|
143
|
|
|
|
|
|
|
also very customizable. It uses its own format though, and my preference for |
|
144
|
|
|
|
|
|
|
dumping is the Perl format (with additional informations/hints as comments) so |
|
145
|
|
|
|
|
|
|
I've never used it in my daily coding activities. I probably should though. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
_ |
|
148
|
|
|
|
|
|
|
}, |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
{ |
|
151
|
|
|
|
|
|
|
module=>'JSON::Color', |
|
152
|
|
|
|
|
|
|
tags => ['json'], |
|
153
|
|
|
|
|
|
|
description => <<'_', |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
JSON is a limited format; it cannot represent many things that Perl supports |
|
156
|
|
|
|
|
|
|
e.g. globs, circular references, or even ASCII NUL. But if you are working only |
|
157
|
|
|
|
|
|
|
with JSON-able data, this JSON dumping module adds color output. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
_ |
|
160
|
|
|
|
|
|
|
}, |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
{ |
|
163
|
|
|
|
|
|
|
module=>'YAML::Tiny::Color', |
|
164
|
|
|
|
|
|
|
tags => ['yaml'], |
|
165
|
|
|
|
|
|
|
description => <<'_', |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
_ |
|
168
|
|
|
|
|
|
|
}, |
|
169
|
|
|
|
|
|
|
], |
|
170
|
|
|
|
|
|
|
}; |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |
|
173
|
|
|
|
|
|
|
# ABSTRACT: List of modules and tips when dumping data structures for debugging |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
__END__ |