Data-Dumper-Compact
view release on metacpan or search on metacpan
],
},
},
where => {
parent_id => undef,
},
},
},
],
},
},
},
],
set => {
path => {
-ident => [
'tree',
'path',
],
},
},
}
Summary
Hopefully it's clear what the goal is, and what we've done to achieve
it.
While the system is already somewhat configurable, further options are
almost certainly implementable, although if you really want such an
option then we expect you to turn up with documentation and test cases
for it so we just have to write the code.
OPTIONS
max_width
Represents the width that DDC will attempt to keep as the maximum (if
something overflows it in spite of our best efforts, DDC will fall back
to a more vertically sprawling format to at least overflow as little as
feasible).
Default: 78
indent_by
The string to indent by. To set e.g. 4 space indent, pass "' 'x4".
Default: ' ' (two spaces).
indent_width
How many characters one indent should be considered to be. Generally you
only need to manually set this if your "indent_by" is "\t".
Default: "length($self->indent_by)"
transforms
Set of transforms to apply on every "dump" operation. See "transform"
for more information.
Default: "[]"
dumper
The dumper function to be used for dumping things DDC doesn't
understand, such as coderefs, regexprefs, etc.
Defaults to the same options as Data::Dumper::Concise (which is, itself,
only a Data::Dumper configuration albeit it comes with Devel::Dwarn
which is rather more interesting) - although on top of that we add a
little bit of extra cleverness to make B::Deparse use the correct
indentation, since for some reason Data::Dumper doesn't (at the time of
writing) do that.
If you supply it yourself, it needs to be a single argument coderef -
you could for example use "\&Data::Dumper::Dumper" though that would
almost certainly be pointless.
EXPORTS
ddc
use Data::Dumper::Compact 'ddc';
use Data::Dumper::Compact 'ddc' => \%options;
If the first argument to "use"/"import()" is 'ddc', a subroutine "ddc()"
is installed in the calling package which behaves like calling "dump".
If the second argument is a hashref, it becomes the options passed to
"new".
This feature is effectively sugar over "dump_cb", in that:
Data::Dumper::Compact->import(ddc => \%options)
is equivalent to:
*ddc = Data::Dumper::Compact->new(\%options)->dump_cb;
METHODS
new
my $ddc = Data::Dumper::Compact->new;
my $ddc = Data::Dumper::Compact->new(%options);
my $ddc = Data::Dumper::Compact->new(\%options);
Constructor. Takes a hash or hashref of "OPTIONS"
dump
my $formatted = Data::Dumper::Compact->dump($data, \%options?);
my $formatted = $ddc->dump($data, \%merge_options?);
This is the method you're going to want to call most of the time, and
ties together the rest of the functionality into a single
data-structure-to-string bundle. With just a data argument, it's
equivalent to:
$ddc->format( $ddc->transform( $ddc->transforms, $ddc->expand($data) );
In class method form, options provided are passed to "new"; in instance
method form, options if provided are merged into $ddc just for this
invocation.
dump_cb
my $cb = $ddc->dump_cb;
Returns a subroutine reference that's a curried call to "dump":
( run in 1.001 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )