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

VERSION
    This document describes version 0.070 of Data::Dump::Partial (from Perl
    distribution Data-Dump-Partial), released on 2024-01-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
     dumpp($data, $more_data, {max_total_len => 50, max_keys => 4});

     # mask passwords specified in hash key values
     dumpp({auth_info=>{user=>"jajang", password=>"secret"}, foo=>1, bar=>2},
           {mask_keys_regex=>qr/\Apass\z|passw(or)?d/i});
     # prints something like:
     # {auth_info=>{user=>"jajang", password=>"***"}, foo=>1, bar=>2}

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 up to a certain amount of data are
    dumped/shown: string longer than a certain length will be truncated
    (with "..." appended in the end), array more than a certain number of
    elements will be truncated, and hash containing more than a certain
    number of pairs will be truncated. The total length of dump is also
    limited. When truncating hash you can specify which keys to
    discard/preserve first. You can also mask certain hash key values (for
    example, to avoid exposing passwords in dumps).

    $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.

    *   mask_keys_regex => REGEX

        When encountering keys that match certain regex, mask the values
        with '***'. This can be useful if you want to mask passwords, e.g.:
        mask_keys_regex => qr/\Apass\z|passw(or)?d/i. If you want more
        general masking, you can use pair_filter.

    *   pair_filter => CODE

        CODE will be called for each hash key/value pair encountered in the
        data. It will be given ($key, $value) as argument and is expected to
        return a list of zero or more of keys and values. The example below
        implements something similar to what mask_keys_regex accomplishes:

         # mask each password character with '*'
         hash_pair_filter => sub {
             my ($k, $v) = @_;
             if ($k =~ /\Apass\z|passw(or)?d/i) {
                 $v =~ s/./*/g;
             }
             ($k, $v);
         }

    *   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.

HOMEPAGE
    Please visit the project's homepage at
    <https://metacpan.org/release/Data-Dump-Partial>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-Data-Dump-Partial>.

SEE ALSO
    Data::Dump::Filtered

AUTHOR
    perlancar <perlancar@cpan.org>

CONTRIBUTOR
    Steven Haryanto <stevenharyanto@gmail.com>

CONTRIBUTING
    To contribute, you can send patches by email/via RT, or send pull
    requests on GitHub.

    Most of the time, you don't need to build the distribution yourself. You
    can simply modify the code, then test via:

     % prove -l

    If you want to build the distribution (e.g. to try to install it locally
    on your system), you can install Dist::Zilla,
    Dist::Zilla::PluginBundle::Author::PERLANCAR,
    Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two
    other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps
    required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE
    This software is copyright (c) 2024, 2023, 2014, 2012, 2010 by perlancar
    <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.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    <https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Dump-Partial>

    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.