DD - Dump data structure for debugging
This document describes version 0.009 of DD (from Perl distribution DD-Dummy), released on 2020-06-05.
To install this module, currently do this:
% cpanm -n DD::Dummy
In your code:
use DD; # exports dd(), dd_warn(), dd_die(), dmp() ... dd $data ; # prints data to STDOUT, return argument my $foo = dd $data ; # ... so you can use it inside expression my $foo = dd_warn $data ; # just like dd() but warns instead dd_die $data ; # just like dd() but dies instead my $dmp = dmp $data ; # dump data as string and return it
On the command-line:
% perl -MDD -E'...; dd $data; ...'
DD is a module with a short name you can use for debugging. It provides "dd" which dumps data structure to STDOUT, as well as return the original data so you can insert dd in the middle of expressions. It also provides "dd_warn", "dd_die", as well as "dmp" for completeness.
DD
dd
DD can use several kinds of backends. The default is Data::Dump which is chosen because it's a mature module and produces visually nice dumps for debugging. You can also use these other backends:
Data::Dmp
Optional dependency. Compact output.
Data::Dump::Color
Optional dependency. Colored output.
Data::Dump::ObjectAsString
Optional dependency.
Data::Dump::Options
Data::Dump::PHP
See also: PHP::Serialization.
Data::Dumper
Optional dependency. A core module.
Data::Dumper::Compact
Data::Format::Pretty::Console
Data::Format::Pretty::SimpleText
Data::Format::Pretty::Text
Data::Printer
JSON::Color
Note that the JSON format cannot handle some kinds of Perl data (e.g. typeglobs, recursive structure). You might want to "clean" the data first before dumping using Data::Clean::ForJSON.
JSON::MaybeXS
JSON::PP
Optional dependency, a core module.
PHP::Serialization
See also: "Data::Dump::PHP".
YAML
YAML::Tiny::Color
Note that this dumper cannot handle some kinds of Perl data (e.g. recursive references). You might want to "clean" the data first before dumping using Data::Clean or Data::Clean::ForJSON.
The backend to use. The default is to use "PERL_DD_BACKEND" environment variable or "Data::Dump" as the fallback default.
Print the dump of its arguments to STDOUT, and return its arguments.
Warn the dump of its arguments, and return its arguments. If you want a full stack trace, you can use Devel::Confess, e.g. on the command-line:
% perl -d:Confess -MDD -E'... dd_warn $data;'
Die with the dump of its arguments as message. If you want a full stack trace, you can use Devel::Confess, e.g. on the command-line:
% perl -d:Confess -MDD -E'... dd_die $data;'
Dump its arguments as string and return it.
Can be used to set the default backend.
Please visit the project's homepage at https://metacpan.org/release/DD-Dummy.
Source repository is at https://github.com/perlancar/perl-DD-Dummy.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=DD-Dummy
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.
XXX - basically the same thing but with different function names and defaults. I happen to use "XXX" to mark todo items in source code, so I prefer other names.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2020, 2019, 2017 by 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.
To install DD::Dummy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DD::Dummy
CPAN shell
perl -MCPAN -e shell install DD::Dummy
For more information on module installation, please visit the detailed CPAN module installation guide.