Scroll to navigation

Dist::Zilla::Role::HashDumper(3pm) User Contributed Perl Documentation Dist::Zilla::Role::HashDumper(3pm)

NAME

Dist::Zilla::Role::HashDumper - Dump selected hash keys as a string

VERSION

This document describes version 4.13 of Dist::Zilla::Role::HashDumper, released December 17, 2017 as part of Dist-Zilla-Plugins-CJM version 6.000.

DESCRIPTION

Plugins implementing HashDumper may call their own "extract_keys" method to extract selected keys from a hash and return a string suitable for injecting into Perl code. They may also call the "hash_as_string" method to do the same for an entire hash.

METHODS

extract_keys

  my $string = $plugin->extract_keys($name, \%hash, @keys);
  eval "%new_hash = ($string);";

This combines "extract_keys_as_hash" and "hash_as_string". It constructs a string of properly quoted keys and values from selected keys in a hash. (Note that "\%hash" is a reference, but @keys is not.) The $name is used only in a log_debug message.

If any key has no value (or its value is an empty hash or array ref) it will be omitted from the list. If all keys are omitted, the empty string is returned. Otherwise, the result always ends with a comma.

extract_keys_as_hash

  my $hashref = $plugin->extract_keys_as_hash($name, \%hash, @keys);

This constructs a hashref from from selected keys in a hash. (Note that "\%hash" is a reference, but @keys is not.) The $name is used only in a log_debug message.

If any key has no value (or its value is an empty hash or array ref) it will be omitted from the new hashref. If all keys are omitted, an empty hashref is returned.

hash_as_string

  my $string = $plugin->hash_as_string(\%hash);
  eval "%new_hash = ($string);";

This constructs a string of properly quoted keys and values from a hash. If the hash is empty, the empty string will be returned. Otherwise, the result always ends with a comma.

CONFIGURATION AND ENVIRONMENT

Dist::Zilla::Role::HashDumper requires no configuration files or environment variables.

DEPENDENCIES

Data::Dumper.

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

AUTHOR

Christopher J. Madsen "<perl AT cjmweb.net>"

Please report any bugs or feature requests to "<bug-Dist-Zilla-Plugins-CJM AT rt.cpan.org>" or through the web interface at <http://rt.cpan.org/Public/Bug/Report.html?Queue=Dist-Zilla-Plugins-CJM>.

You can follow or contribute to Dist-Zilla-Plugins-CJM's development at <https://github.com/madsen/dist-zilla-plugins-cjm>.

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Christopher J. Madsen.

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

DISCLAIMER OF WARRANTY

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 LICENSE, 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.

2022-06-13 perl v5.34.0