| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Format::Pretty::Perl; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
674
|
use 5.010001; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
45
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1092
|
use Data::Dump qw(); |
|
|
1
|
|
|
|
|
10635
|
|
|
|
1
|
|
|
|
|
33
|
|
|
8
|
1
|
|
|
1
|
|
1078
|
use Data::Dump::Color qw(); |
|
|
1
|
|
|
|
|
26169
|
|
|
|
1
|
|
|
|
|
406
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(format_pretty); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
1
|
0
|
sub content_type { "text/x-perl" } |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub format_pretty { |
|
19
|
1
|
|
|
1
|
1
|
844
|
my ($data, $opts) = @_; |
|
20
|
1
|
|
50
|
|
|
5
|
$opts //= {}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
13
|
my $interactive = (-t STDOUT); |
|
23
|
1
|
|
33
|
|
|
17
|
my $color = $opts->{color} // $ENV{COLOR} // $interactive; |
|
|
|
|
33
|
|
|
|
|
|
24
|
1
|
|
33
|
|
|
10
|
my $linum = $opts->{linum} // $ENV{LINUM} // 0; |
|
|
|
|
50
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
3
|
my $dump; |
|
27
|
1
|
50
|
|
|
|
4
|
if ($color) { |
|
28
|
0
|
|
|
|
|
0
|
$dump = Data::Dump::Color::dump($data) . "\n"; |
|
29
|
|
|
|
|
|
|
} else { |
|
30
|
1
|
|
|
|
|
9
|
$dump = Data::Dump::dump($data) . "\n"; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
1
|
50
|
|
|
|
436
|
if ($linum) { |
|
33
|
0
|
|
|
|
|
0
|
my $lines = 0; |
|
34
|
0
|
|
|
|
|
0
|
$lines++ while $dump =~ /^/mog; |
|
35
|
0
|
|
|
|
|
0
|
my $fmt; |
|
36
|
0
|
|
|
|
|
0
|
my $i = 0; |
|
37
|
0
|
0
|
|
|
|
0
|
if ($color) { |
|
38
|
0
|
|
|
|
|
0
|
$fmt = "%".length($lines)."d"; |
|
39
|
0
|
|
|
|
|
0
|
$dump =~ s/^/ |
|
40
|
0
|
|
|
|
|
0
|
"\e[7m" . sprintf($fmt, ++$i) . "\e[0m" |
|
41
|
|
|
|
|
|
|
/egm; |
|
42
|
|
|
|
|
|
|
} else { |
|
43
|
0
|
|
|
|
|
0
|
$fmt = "%".length($lines)."d|"; |
|
44
|
0
|
|
|
|
|
0
|
$dump =~ s/^/ |
|
45
|
0
|
|
|
|
|
0
|
sprintf($fmt, ++$i) |
|
46
|
|
|
|
|
|
|
/egm; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
1
|
|
|
|
|
4
|
$dump; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
|
53
|
|
|
|
|
|
|
# ABSTRACT: Pretty-print data structure as Perl code |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |