1Data::Dumper::Concise(3U)ser Contributed Perl DocumentatiDoanta::Dumper::Concise(3)
2
3
4
6 Data::Dumper::Concise - Less indentation and newlines plus sub
7 deparsing
8
10 use Data::Dumper::Concise;
11
12 warn Dumper($var);
13
14 is equivalent to:
15
16 use Data::Dumper;
17 {
18 local $Data::Dumper::Terse = 1;
19 local $Data::Dumper::Indent = 1;
20 local $Data::Dumper::Useqq = 1;
21 local $Data::Dumper::Deparse = 1;
22 local $Data::Dumper::Quotekeys = 0;
23 local $Data::Dumper::Sortkeys = 1;
24 warn Dumper($var);
25 }
26
27 whereas
28
29 my $dd = Dumper;
30
31 is equivalent to:
32
33 my $dd = Data::Dumper->new([])
34 ->Terse(1)
35 ->Indent(1)
36 ->Useqq(1)
37 ->Deparse(1)
38 ->Quotekeys(0)
39 ->Sortkeys(1);
40
41 So for the structure:
42
43 { foo => "bar\nbaz", quux => sub { "fleem" } };
44
45 Data::Dumper::Concise will give you:
46
47 {
48 foo => "bar\nbaz",
49 quux => sub {
50 use warnings;
51 use strict 'refs';
52 'fleem';
53 }
54 }
55
56 instead of the default Data::Dumper output:
57
58 $VAR1 = {
59 'quux' => sub { "DUMMY" },
60 'foo' => 'bar
61 baz'
62 };
63
64 (note the tab indentation, oh joy ...)
65
67 This module always exports a single function, Dumper, which can be
68 called with an array of values to dump those values or with no
69 arguments to return the Data::Dumper object it's created. Note that
70 this means that
71
72 Dumper @list
73
74 will probably not do what you wanted when @list is empty. In this case
75 use
76
77 Dumper \@list
78
79 instead.
80
81 It exists, fundamentally, as a convenient way to reproduce a set of
82 Dumper options that we've found ourselves using across large numbers of
83 applications, primarily for debugging output.
84
85 The principle guiding theme is "all the concision you can get while
86 still having a useful dump and not doing anything cleverer than setting
87 Data::Dumper options" - it's been pointed out to us that
88 Data::Dump::Streamer can produce shorter output with less lines of
89 code. We know. This is simpler and we've never seen it segfault. But
90 for complex/weird structures, it generally rocks. You should use it as
91 well, when Concise is underkill. We do.
92
93 Why is deparsing on when the aim is concision? Because you often want
94 to know what subroutine refs you have when debugging and because if you
95 were planning to eval this back in you probably wanted to remove
96 subrefs first and add them back in a custom way anyway. Note that this
97 -does- force using the pure perl Dumper rather than the XS one, but
98 I've never in my life seen Data::Dumper show up in a profile so "who
99 cares?".
100
102 Yes, we know. Consider this module in the ::Tiny spirit and feel free
103 to write a Data::Dumper::Concise::ButWithExtraTwiddlyBits if it makes
104 you happy. Then tell us so we can add it to the see also section.
105
107 This package also provides:
108
109 Data::Dumper::Concise::Sugar - provides Dwarn and DwarnS convenience
110 functions
111
112 Devel::Dwarn - shorter form for Data::Dumper::Concise::Sugar
113
115 We use for some purposes, and dearly love, the following alternatives:
116
117 Data::Dump - prettiness oriented but not amazingly configurable
118
119 Data::Dump::Streamer - brilliant. beautiful. insane. extensive.
120 excessive. try it.
121
122 JSON::XS - no, really. If it's just plain data, JSON is a great option.
123
125 mst - Matt S. Trout <mst@shadowcat.co.uk>
126
128 frew - Arthur Axel "fREW" Schmidt <frioux@gmail.com>
129
131 Copyright (c) 2009 the Data::Dumper::Concise "AUTHOR" and
132 "CONTRIBUTORS" as listed above.
133
135 This library is free software and may be distributed under the same
136 terms as perl itself.
137
138
139
140perl v5.12.0 2010-02-13 Data::Dumper::Concise(3)