Data::Dumper::AutoEncode - Dump with recursive encoding
use utf8; use Data::Dumper::AutoEncode; eDumper(+{ foo => 'おでん' })
Data::Dumper::AutoEncode stringifies perl data structures including unicode string to human-readable.
example:
use utf8; use Data::Dumper; my $foo = +{ foo => 'おでん' }; print Dumper($foo);
It will dump like this
{ foo => "\x{304a}\x{3067}\x{3093}" }
This is not human-readable.
Data::Dumper::AutoEncode exports `eDumper` function. You can use it.
use utf8; use Data::Dumper::AutoEncode; my $foo = +{ foo => 'おでん' }; print eDumper($foo); # { foo => "おでん" }
Also `Dumper` function is exported from Data::Dumper::AutoEncode. It is same as Data::Dumper::Dumper
By default, both functions eDumper and Dumper will be exported.
Dump with recursive encoding(default: utf8)
If you want to encode other encoding, set encoding to $Data::Dumper::AutoEncode::ENCODING.
$Data::Dumper::AutoEncode::ENCODING = 'CP932';
Same as the Dumper function of Data::Dumper. However, if you specify an import option -dumper, then the Dumper function will work as same as eDumper function. Please see IMPORT OPTIONS section for more details.
Dumper
-dumper
eDumper
IMPORT OPTIONS
Just encode stuff.
You can specify an import option to override Dumper function.
use Data::Dumper::AutoEncode '-dumper';
It means Dumper function is overrided as same as eDumper.
Set this option if you need another encoding;
Set code ref for hooks which excuted around encoding
$Data::Dumper::AutoEncode::BEFORE_HOOK = sub { my $value = $_[0]; # decoded $value =~ s/\x{2019}/'/g; return $value; }; $Data::Dumper::AutoEncode::AFTER_HOOK = sub { my $value = $_[0]; # encoded // do something return $value; };
If you set this option true value, check a target before encoding. And do encode in case of decoded value.
By default, numeric values are ignored (do nothing).
Additional string (prefix) for encoded values.
This Data::Dumper::AutoEncode is using Data::Dumper internally. So, you can set configuration variables to dump as the variables of Data::Dumper, like below.
Data::Dumper::AutoEncode
use Data::Dumper::AutoEncode; local $Data::Dumper::Indent = 2; local $Data::Dumper::Sortkeys = 1; local $Data::Dumper::Deparse = 1; say eDumper($hash);
Data::Dumper::AutoEncode is hosted on github http://github.com/bayashi/Data-Dumper-AutoEncode
Dai Okabayashi <bayashi@cpan.org>
Data::Dumper
gfx
tomyhero
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Data::Dumper::AutoEncode, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Dumper::AutoEncode
CPAN shell
perl -MCPAN -e shell install Data::Dumper::AutoEncode
For more information on module installation, please visit the detailed CPAN module installation guide.