| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
## no critic: TestingAndDebugging::RequireUseStrict |
|
2
|
|
|
|
|
|
|
package Data::MiniDumpX; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# IFUNBUILT |
|
5
|
|
|
|
|
|
|
# use strict; |
|
6
|
|
|
|
|
|
|
# use warnings; |
|
7
|
|
|
|
|
|
|
# END IFUNBUILT |
|
8
|
1
|
|
|
1
|
|
380402
|
use Log::ger; |
|
|
1
|
|
|
|
|
60
|
|
|
|
1
|
|
|
|
|
7
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
274
|
use Exporter qw(import); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
54
|
|
|
11
|
|
|
|
|
|
|
use Plugin::System ( |
|
12
|
1
|
|
|
|
|
11
|
hooks => { |
|
13
|
|
|
|
|
|
|
dump => {}, |
|
14
|
|
|
|
|
|
|
dump_scalar => {}, |
|
15
|
|
|
|
|
|
|
dump_array => {}, |
|
16
|
|
|
|
|
|
|
dump_hash => {}, |
|
17
|
|
|
|
|
|
|
dump_unknown_ref => {}, |
|
18
|
|
|
|
|
|
|
}, |
|
19
|
1
|
|
|
1
|
|
720
|
); |
|
|
1
|
|
|
|
|
961
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
22
|
|
|
|
|
|
|
our $DATE = '2024-03-02'; # DATE |
|
23
|
|
|
|
|
|
|
our $DIST = 'Data-MiniDumpX'; # DIST |
|
24
|
|
|
|
|
|
|
our $VERSION = '0.000001'; # VERSION |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our @EXPORT = qw(dd); ## no critic: Modules::ProhibitAutomaticExportation |
|
27
|
|
|
|
|
|
|
our @EXPORT_OK = qw(dump); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my %esc = ( |
|
30
|
|
|
|
|
|
|
"\a" => "\\a", |
|
31
|
|
|
|
|
|
|
"\b" => "\\b", |
|
32
|
|
|
|
|
|
|
"\t" => "\\t", |
|
33
|
|
|
|
|
|
|
"\n" => "\\n", |
|
34
|
|
|
|
|
|
|
"\f" => "\\f", |
|
35
|
|
|
|
|
|
|
"\r" => "\\r", |
|
36
|
|
|
|
|
|
|
"\e" => "\\e", |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# from Data::Dump |
|
40
|
|
|
|
|
|
|
sub _quote { |
|
41
|
0
|
|
|
0
|
|
|
local($_) = $_[0]; |
|
42
|
|
|
|
|
|
|
# If there are many '"' we might want to use qq() instead |
|
43
|
0
|
|
|
|
|
|
s/([\\\"\@\$])/\\$1/g; |
|
44
|
0
|
0
|
|
|
|
|
return qq("$_") unless /[^\040-\176]/; # fast exit |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
s/([\a\b\t\n\f\r\e])/$esc{$1}/g; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# no need for 3 digits in escape for these |
|
49
|
0
|
|
|
|
|
|
s/([\0-\037])(?!\d)/sprintf('\\%o',ord($1))/eg; |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
s/([\0-\037\177-\377])/sprintf('\\x%02X',ord($1))/eg; |
|
|
0
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
s/([^\040-\176])/sprintf('\\x{%X}',ord($1))/eg; |
|
|
0
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return qq("$_"); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _str { |
|
58
|
0
|
|
|
0
|
|
|
_quote(shift); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub dump { |
|
62
|
0
|
|
|
0
|
1
|
|
my $data = shift; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
hook_dump { |
|
65
|
0
|
|
|
0
|
|
|
my $ref = ref $data; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if (!$ref) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
hook_dump_scalar { _str($data) }; |
|
|
0
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} elsif ($ref eq 'ARRAY') { |
|
70
|
0
|
|
|
|
|
|
"[" . (hook_dump_array { join(", ", map { &dump($_) } @$data) }) . "]"; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} elsif ($ref eq 'HASH') { |
|
72
|
0
|
|
|
|
|
|
"{" . (hook_dump_hash { join(", ", map { _quote($_) . ' => ' . &dump($data->{$_}) } sort keys %$data) }) . "}"; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} else { |
|
74
|
|
|
|
|
|
|
hook_dump_unknown_ref { |
|
75
|
0
|
|
|
|
|
|
die "Unsupported ref '$ref'"; |
|
76
|
0
|
|
|
|
|
|
}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
0
|
|
|
|
|
|
}; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub dd { |
|
82
|
0
|
|
|
0
|
1
|
|
my $data = shift; |
|
83
|
0
|
|
|
|
|
|
my $dump = &dump($data); |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
print $dump; |
|
86
|
0
|
0
|
|
|
|
|
print "\n" unless $dump =~ /\R\z/; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$data; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
|
92
|
|
|
|
|
|
|
# ABSTRACT: A simplistic data structure dumper (demo for Plugin::System) |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |