D - Provides utility functions to encode data and dump it to STDERR.
use utf8; # Export du, dw, de, dn, dustr, dwstr, destr, dnstr functions use D; # Reference data that contains decoded strings my $data = [{name => 'あ'}, {name => 'い'}]; # Encode all strings in reference data to UTF-8 and dump the reference data to STDERR. du $data; # Encode all strings in reference data to cp932 and dump the reference data to STDERR. dw $data; # Encode all strings in reference data to EUC-JP and dump the reference data to STDERR. de $data; # Dump reference data to STDERR without encoding. dn $data; # Examples of useful oneliner. use D;du $data; use D;dw $data; use D;de $data; use D;dn $data; # Output example of du function. [ { 'name' => 'あ' }, { 'name' => 'い' } ] at test.pl line 7.
D module provides utility functions to encode data and dump it to STDERR.
Export du, dw, de, and dn functions. Don't conflict debug command such as 'p' because these function names are consist of two characters.
du
dw
de
dn
Encode all strings in reference data in dustr, dwstr, and destr function.
dustr
dwstr
destr
du is a short name of "dump UTF-8"
dw is a short name of "dump Windows cp932"
de is a short name of "dump EUC-JP"
dn is a short name of "dump no encoding"
Use Dump method of Data::Dumper to dump data
Dump
Print line number and file name to STDERR
Keys of hash of dumped data is sorted.
Don't print "$VAR1 =" unlike Data::Dumper default.
Encode all strings in reference data to UTF-8 and return string the reference data with file name and line number.
If the argument is not reference data such as a string, it is also dumped in the same way as reference data.
This function is exported.
use D; my $data = [{name => 'あ'}, {name => 'い'}]; du $data;
Following example is oneliner used. It can be used all functions.
my $data = [{name => 'あ'}, {name => 'い'}]; use D;du $data;
Encode all strings in reference data to cp932 and dump the reference data to STDERR with file name and line number.
use D; my $data = [{name => 'あ'}, {name => 'い'}]; dw $data;
Encode all strings in reference data to EUC-JP and dump the reference data to STDERR with file name and line number.
use D; my $data = [{name => 'あ'}, {name => 'い'}]; de $data;
Dump reference data to STDERR without encoding with file name and line number.
use D; my $data = [{name => 'あ'}, {name => 'い'}]; dn $data;
This function is return that UTF-8 encoded string.
Following example is get the UTF-8 encoded string.
use D; my $data = [{name => 'あ'}, {name => 'い'}]; my $str = dustr $data;
This function is return that cp932 encoded string.
Following example is get the cp932 encoded string.
use D; my $data = [{name => 'あ'}, {name => 'い'}]; my $str = dwstr $data;
This function is return that EUC-JP encoded string.
Following example is get the EUC-JP encoded string.
use D; my $data = [{name => 'あ'}, {name => 'い'}]; my $str = destr $data;
This function is return that without encoded string.
Following example is get the without encoded string.
use D; my $data = [{name => 'あ'}, {name => 'い'}]; my $str = dnstr $data;
https://github.com/YoshiyukiItoh/D
Data::Dumper, Carp, Data::Recursive::Encode
Yoshiyuki Ito, <yoshiyuki.ito.biz@gmail.com>
Yuki Kimoto, <kimoto.yuki@gmail.com>
Copyright (C) 2019 by Yoshiyuki Ito, Yuki Kimoto
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.08.7 or, at your option, any later version of Perl 5 you may have available.
To install D, copy and paste the appropriate command in to your terminal.
cpanm
cpanm D
CPAN shell
perl -MCPAN -e shell install D
For more information on module installation, please visit the detailed CPAN module installation guide.