GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Data::Dump::Color(3) User Contributed Perl Documentation Data::Dump::Color(3)

Data::Dump::Color - Like Data::Dump, but with color

This document describes version 0.251 of Data::Dump::Color (from Perl distribution Data-Dump-Color), released on 2025-02-21.

Use it like you would Data::Dump, e.g.:

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

Sample screenshots:

This module aims to be a drop-in replacement for Data::Dump. It adds colors to dumps. It also adds various visual aids in the comments, e.g. array/hash index, depth indicator, and so on.

For more information, see Data::Dump. This documentation explains what's different between this module and Data::Dump.

By default Data::Dump::Color shows array index or hash pair sequence in comments for visual aid, e.g.:

 [
   "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]
 ]

"[]" and "{}" brackets will indicate whether they are indexes to an array or a hash. The dot prefixes will mark depth level.

To turn this off, set $INDEX to 0:

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

"$Data::Dump::*" package variables from Data::Dump, like $Data::Dump::TRY_BASE64, etc are now in the "Data::Dump::Color" namespace, e.g. $Data::Dump::Color::TRY_BASE64, etc.

Additional variables include:

$COLOR => BOOL (default: undef)
Whether to force-enable or disable color. If unset, color output will be determined from "NO_COLOR", "COLOR" environment variables, or whether running in interactive terminal (when "-t STDOUT" is true).
$COLOR_THEME => str
Select a color theme, which is a module under "ColorTheme::Data::Dump::Color::" or "ColorTheme::" namespace (with/without the namespace prefix). For example: "Default256", "Bright".
$INDEX => BOOL (default: 1)
Whether to add array/hash index visual aid.
$LENTHRESHOLD => int (default: 500)
Add string length visual aid for hash key/hash value/array element if length is at least this value.

Only "dd" and "ddx" are exported by default.

Set $Data::Dump::Color::INDEX to 0.

Well, colors is sort of the point of this module. But if you want to turn it off, you can set environment COLOR to 0, or $Data::Dump::Color::COLOR to 0.

Create a color theme and give it a name under "ColorTheme::Data::Dump::Color::*". See an existing color theme for example, e.g. ColorTheme::Data::Dump::Color::Default256.

Set color theme. Name will be searched under "ColorTheme::Data::Dump::Color::*" or "ColorTheme::*".

Can be used to disable color. Takes precedence over the "COLOR" environment. See <https://no-color.org> for more details.

If set, then will force color output on or off. By default, will only output color when in interactive terminal. This is consulted when $COLOR is not set.

Please visit the project's homepage at <https://metacpan.org/release/Data-Dump-Color>.

Source repository is at <https://github.com/perlancar/perl-Data-Dump-Color>.

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

perlancar <perlancar@cpan.org>

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

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

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

 % prove -l

If you want to build the distribution (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.

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.

2025-02-21 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.