Data::Dx - Dump data structures with name and point-of-origin
This document describes Data::Dx version 0.000010
use Data::Dx; Dx %foo; Dx @bar; Dx ( @bar, $baz, ); Dx $baz; Dx $ref; Dx @bar[do{1..2;}]; Dx 2*3; Dx 'a+b'; Dx 100 * sqrt length $baz; Dx $foo{q[;{{{]};
This module provides a simple wrapper around the Data::Dump module.
The Dx keyword data-dumps its arguments, prefaced by a comment line that reports the location from which Dx was invoked.
Dx
For example, the code in the SYNOPSIS would produce something like:
#line 19 demo.pl %foo = { "foo" => 1, "food" => 2, "fool" => [1 .. 10], } #line 20 demo.pl @bar = ["b", "a", "r"] #line 21 demo.pl ( @bar, $baz, ) = ["b", "a", "r", "baz"] #line 25 demo.pl $baz = "baz" #line 26 demo.pl $ref = ["b", "a", "r"] #line 27 demo.pl @bar[do{1..2;}] = ["a", "r"] #line 28 demo.pl 2*3 = 6 #line 29 demo.pl 'a+b' = "a+b" #line 30 demo.pl 100 * sqrt length $baz = 173.205080756888 #line 31 demo.pl $foo{q[;{{{]} = undef
If the Term::ANSIColor module is available, the output will also be colour-coded (unless the 'colour' option is specified as false...see below).
'colour'
Dx expr
This is the only keyword provided by the module. It is always exported.
Dx can be called with any number of arguments and data-dumps them all. Dx is a keyword, not a function, so it cannot be used as an rvalue and does not return a useful value.
no Data::Dx;
If the module is imported with no instead of use, it still exports the Dx keyword, but as a no-op.
no
use
This means that you can leave every Dx in your code but disable them all (or just all of them in a given scope) by changing the original use Data::Dx to no Data::Dx
use Data::Dx
no Data::Dx
use Data::Dx { colour => 0 };
If the module is imported with the 'colour' option set false, output is dumped without colouring, even if Term::ANSIColor is available.
The option defaults to true if STDERR is directed to a terminal, and to false otherwise.
STDERR
If you want coloured output even when STDERR isn't directed to a terminal, specify it explicitly like this:
use Data::Dx { colour => 1 };
None, apart from those provided by Data::Dump;
Data::Dx requires no configuration files or environment variables.
Requires the Data::Dump and Keyword::Declare modules.
If you want syntax colouring on the dumps, also requires the Term::ANSIColor module (plus Win32::Console::ANSI under Windows)
Only works under Perl 5.12 and later (the release in which pluggable keywords were added to Perl).
Does not work under Perl 5.20 (due to problems with regex compilation exposed by the Keyword::Declare module under that release).
None reported.
No bugs have been reported.
Please report any bugs or feature requests to bug-data-dx@rt.cpan.org, or through the web interface at http://rt.cpan.org.
bug-data-dx@rt.cpan.org
Damian Conway <DCONWAY@CPAN.org>
<DCONWAY@CPAN.org>
Copyright (c) 2010-2017, Damian Conway <DCONWAY@CPAN.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
To install Data::Dx, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Dx
CPAN shell
perl -MCPAN -e shell install Data::Dx
For more information on module installation, please visit the detailed CPAN module installation guide.