NAME

Data::Dump::Partial - Dump data structure compactly and potentially partially

VERSION

version 0.02

SYNOPSIS

use Data::Dump::Partial qw(dump_partial dumpp);

dump_partial([1, "some long string", 3, 4, 5, 6, 7]);
# prints something like: [1, "some long st...", 3, 4, 5, ...]

# specify options
dump_partial($data, $more_data, {max_total_len => 50, max_keys => 4});

DESCRIPTION

FUNCTIONS

dump_partial(..., $opts)

Dump one more data structures compactly and potentially partially. Uses Data::Dump::Filtered as the backend. By compactly, it means all indents and comments and newlines are removed, so the output all fits in one line. By partially, it means only a certain number of scalar length, array elements, hash keys are showed.

$opts is a hashref, optional only when there is one data to dump, with the following known keys:

  • max_total_len => NUM

    Total length of output before it gets truncated with an ellipsis. Default is 80.

  • max_len => NUM

    Maximum length of a scalar (string, etc) to show before the rest get truncated with an ellipsis. Default is 32.

  • max_keys => NUM

    Number of key pairs of a hash to show before the rest get truncated with an ellipsis. Default is 5.

  • max_elems => NUM

    Number of elements of an array to show before the rest get truncated with an ellipsis. Default is 5.

  • precious_keys => [KEY, ...]

    Never truncate these keys (even if it results in max_keys limit being exceeded).

  • worthless_keys => [KEY, ...]

    When needing to truncate hash keys, search for these first.

  • hide_keys => [KEY, ...]

    Always truncate these hash keys, no matter what. This is actually also implemented by Data::Dump::Filtered.

  • dd_filter => \&sub

    If you have other Data::Dump::Filtered filter you want to execute, you can pass it here.

dumpp

An alias for dump_filtered().

FAQ

What is the point/purpose of this module?

Sometimes you want to dump a data structure, but need it to be short, more than need it to be complete, for example when logging to log files or database.

Is the dump result eval()-able? Will the dump result eval() to produce the original data?

Sometimes it is/will, sometimes it does/will not if it gets truncated.

SEE ALSO

Data::Dump::Filtered

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.