1Data::Dump::Color(3) User Contributed Perl Documentation Data::Dump::Color(3)
2
3
4
6 Data::Dump::Color - Like Data::Dump, but with color
7
9 This document describes version 0.240 of Data::Dump::Color (from Perl
10 distribution Data-Dump-Color), released on 2018-01-17.
11
13 Use it like you would Data::Dump, e.g.:
14
15 use Data::Dump::Color; dd localtime;
16
18 This module aims to be a drop-in replacement for Data::Dump. It adds
19 colors to dumps. It also adds various visual aids in the comments, e.g.
20 array/hash index, depth indicator, and so on.
21
22 For more information, see Data::Dump. This documentation explains
23 what's different between this module and Data::Dump.
24
26 By default Data::Dump::Color shows array index or hash pair sequence in
27 comments for visual aid, e.g.:
28
29 [
30 "this", # [0]
31 "is", # [1]
32 "a", # [2]
33 "5-element", # [3]
34 "array", # [4]
35 {
36 0 => "with", # .{0}
37 1 => "an", # .{1}
38 2 => "extra", # .{2}
39 3 => "hash", # .{3}
40 4 => "at", # .{4}
41 5 => "the", # .{5}
42 16 => "end", # .{6}
43 }, # [5]
44 ]
45
46 "[]" and "{}" brackets will indicate whether they are indexes to an
47 array or a hash. The dot prefixes will mark depth level.
48
49 To turn this off, set $INDEX to 0:
50
51 [
52 "this",
53 "is",
54 "a",
55 "5-element",
56 "array",
57 {
58 0 => "with",
59 1 => "an",
60 2 => "extra",
61 3 => "hash",
62 4 => "at",
63 5 => "the",
64 16 => "end",
65 },
66 ]
67
69 "$Data::Dump::*" package variables from Data::Dump, like
70 $Data::Dump::TRY_BASE64, etc are now in the "Data::Dump::Color"
71 namespace, e.g. $Data::Dump::Color::TRY_BASE64, etc.
72
73 Additional variables include:
74
75 $COLOR => BOOL (default: undef)
76 Whether to force-enable or disable color. If unset, color output
77 will be determined from $ENV{COLOR} or when in interactive terminal
78 (when "-t STDOUT" is true).
79
80 %COLORS => HASH (default: default colors)
81 Define colors.
82
83 $INDEX => BOOL (default: 1)
84 Whether to add array/hash index visual aid.
85
86 $LENTHRESHOLD => int (default: 500)
87 Add string length visual aid for hash key/hash value/array element
88 if length is at least this value.
89
91 How do I turn off index comments?
92 Set $Data::Dump::Color::INDEX to 0.
93
94 How do I turn off colors?
95 Well, colors is sort of the point of this module. But if you want to
96 turn it off, you can set environment COLOR to 0, or
97 $Data::Dump::Color::COLOR to 0.
98
99 How do I customize colors?
100 Fiddle the colors in %Data::Dump::Color::COLORS. There will probably be
101 proper color theme support in the future (based on
102 SHARYANTO::Role::ColorTheme.
103
105 ยท COLOR
106
107 If set, then will force color output on or off. By default, will
108 only output color when in interactive terminal. This is consulted
109 when $COLOR is not set.
110
112 Please visit the project's homepage at
113 <https://metacpan.org/release/Data-Dump-Color>.
114
116 Source repository is at
117 <https://github.com/perlancar/perl-Data-Dump-Color>.
118
120 Please report any bugs or feature requests on the bugtracker website
121 <https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Dump-Color>
122
123 When submitting a bug or request, please include a test-file or a patch
124 to an existing test-file that illustrates the bug or desired feature.
125
127 Data::Dump, JSON::Color, YAML::Tiny::Color
128
130 perlancar <perlancar@cpan.org>
131
133 This software is copyright (c) 2018, 2014, 2013, 2012 by
134 perlancar@cpan.org.
135
136 This is free software; you can redistribute it and/or modify it under
137 the same terms as the Perl 5 programming language system itself.
138
139
140
141perl v5.28.0 2018-01-17 Data::Dump::Color(3)