Data::Dump::Color(3)

πŸ“¦
version 0.251 Β· 2 versions
, in fedora 43

πŸ’– Data::Dump::Color πŸ’–

okay bestie, so this is the manual page for Data::Dump::Color(3) β€” User Contributed Perl Documentation, no cap. it's like Data::Dump but make it fashion 🌈✨


✨ VERSION ✨

this doc is describing version 0.251 of Data::Dump::Color (from the Perl distribution Data-Dump-Color), which dropped on 2025-02-21. yes queen, fresh. πŸŽ€


🌸 SYNOPSIS 🌸

use it exactly like you'd use Data::Dump, fr fr:

use Data::Dump::Color; dd localtime;

that's it. that's the whole vibe. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Sample screenshots:

this module is lowkey trying to be a drop-in replacement for Data::Dump β€” but it adds colors to your dumps (the whole point, obviously 🎨) and also sprinkles in various visual aids inside the comments, like array/hash index, a depth indicator, and so on. it's giving glow-up.

for more deets, go look at Data::Dump. this documentation right here is specifically explaining what's different between this module and Data::Dump. iykyk.


πŸ‘‘ RESULTS πŸ‘‘

by default, Data::Dump::Color shows the array index or hash pair sequence in the comments as a visual aid, like this:

[
  "this",      # [0]
  "is",        # [1]
  "a",         # [2]
  "5-element", # [3]
  "array",     # [4]
  {
    0  => "with",  # .{0}
    1  => "an",    # .{1}
    2  => "extra", # .{2}
    3  => "hash",  # .{3}
    4  => "at",    # .{4}
    5  => "the",   # .{5}
    16 => "end",   # .{6}
  },           # [5]
]

the [] and {} brackets tell you whether you're looking at indexes into an array or into a hash. and the dot prefixes mark the depth level. so . = one level deep, etc. periodt.

wanna turn this off? set $INDEX to 0 and watch the comments simply leave:

[
  "this",
  "is",
  "a",
  "5-element",
  "array",
  {
    0  => "with",
    1  => "an",
    2  => "extra",
    3  => "hash",
    4  => "at",
    5  => "the",
    16 => "end",
  },
]

clean. minimal. also valid. 🫢


πŸ’œ VARIABLES πŸ’œ

all the $Data::Dump::* package variables from Data::Dump β€” like $Data::Dump::TRY_BASE64, etc β€” now live in the Data::Dump::Color namespace instead. so for example: $Data::Dump::Color::TRY_BASE64, etc. they moved out, got a new address, still iconic. πŸ“¦

and there are additional variables too:

  • $COLOR => BOOL (default: undef) β€” whether to force-enable or disable color. if it's unset, then color output gets determined from the NO_COLOR and COLOR environment variables, or from whether you're running in an interactive terminal (specifically when -t STDOUT is true). so like, it figures itself out, bestie.
  • $COLOR_THEME => str β€” pick a color theme. a theme is a module under the ColorTheme::Data::Dump::Color:: namespace or the ColorTheme:: namespace (you can use it with or without the namespace prefix, we're not picky). for example: Default256, Bright. 🎨
  • $INDEX => BOOL (default: 1) β€” whether to add that array/hash index visual aid. defaults to on, because we do like nice things.
  • $LENTHRESHOLD => int (default: 500) β€” add the string length visual aid for hash key / hash value / array element whenever the length is at least this value. so 500+ characters? it gets flagged. πŸ’€

πŸ”₯ FUNCTIONS πŸ”₯

only dd and ddx get exported by default. dump is there too, it's just not automatic β€” you gotta invite it. πŸ™ˆ

dd

ddx

dump


🧚 FAQ 🧚

How do I turn off index comments?

set $Data::Dump::Color::INDEX to 0. boom, gone. ✨

How do I turn off colors?

okay so, colors are kinda the whole point of this module 😭 but if you really must, you can set the environment variable COLOR to 0, or set $Data::Dump::Color::COLOR to 0. your call, bestie.

How do I customize colors?

create a color theme and give it a name under ColorTheme::Data::Dump::Color::*. peek at an existing color theme for an example β€” like ColorTheme::Data::Dump::Color::Default256. go forth and theme it up. 🌈


🌟 ENVIRONMENT 🌟

DATA_DUMP_COLOR_THEME

set the color theme. the name will be searched under ColorTheme::Data::Dump::Color::* or ColorTheme::*. πŸ”

NO_COLOR

can be used to disable color. it takes precedence over the COLOR environment variable. see <https://no-color.org> for more details.

COLOR

if set, then it forces color output on or off. by default, color is only output when in an interactive terminal. this one is consulted when $COLOR is not set.


🏠 HOMEPAGE 🏠

please visit the project's homepage at <https://metacpan.org/release/Data-Dump-Color>. πŸ’–


πŸ“ SOURCE πŸ“

source repository is at <https://github.com/perlancar/perl-Data-Dump-Color>. go look, go star, go contribute.


⭐ SEE ALSO ⭐

Data::Dump, JSON::Color, YAML::Tiny::Color


πŸ’« AUTHOR πŸ’«

perlancar <perlancar@cpan.org>


πŸ’ CONTRIBUTORS πŸ’

  • Scott Baker <bakerscot@cpan.org>
  • Steven Haryanto <stevenharyanto@gmail.com>

πŸŽ€ CONTRIBUTING πŸŽ€

to contribute, you can send patches by email / via RT, or send pull requests on GitHub. we love a patch girlie. 🫢

most of the time, you don't need to build the distribution yourself. you can simply modify the code, then test it via:

% prove -l

if you do want to build the distribution (like, e.g., to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. any additional steps required beyond that are considered a bug and can be reported to me. πŸ’…


this software is copyright (c) 2025 by perlancar <perlancar@cpan.org>.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


πŸ’€ BUGS πŸ’€

please report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Dump-Color>.

when submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. help me help you bestie, receipts please. πŸ“


and that's the whole page, mwah πŸ’‹ this was written against perl v5.42.0, and the page itself is dated 2025-07-25 β€” stay slay, stay colored πŸŒˆβœ¨πŸ’–
πŸ“¦ where this page comes from