NAME

D - Provides utility functions to encode data and dump it to STDERR.

SYNOPSIS

use utf8;

# Export du, dw, dn, dustr, dwstr, dnstr functions
use D;

# Reference data that contains decoded strings
my $data = [{name => 'あ'}, {name => 'い'}];

# Encode all strings in reference data to UTF-8 and return string the reference data.
my $str = dustr $data;

# Encode all strings in reference data to cp932 and return string the reference data.
my $str = dwstr $data;

# Return string the reference data to without encoding.
my $str = dnstr $data;

# Dump the result of dustr function to STDERR.
du $data;

# Dump the result of dwstr function to STDERR.
dw $data;

# Dump the result of dnstr function to STDERR.
dn $data;

DESCRIPTION

D module provides utility functions to encode data and dump it to STDERR.

FEATURES

  • Export du and dw and dn and dustr and dwstr and dnstr functions. Don't conflict debug command such as 'p' because these function names are consist of two characters.

  • Encode all strings in reference data in dustr and dwstr function.

  • du is a short name of "dump UTF-8"

  • dw is a short name of "dump Windows cp932"

  • dn is a short name of "dump no encoding"

  • Onliner is useful. "useD;du $data;" or "useD;dw $data;" or "useD;dn $data;"

  • Use Dump method of Data::Dumper to dump data

  • Print line number and file name to STDERR

  • Keys of hash of dumped data is sorted.

  • Don't print "$VAR1 =" unlike Data::Dumper default.

EXPORT

Export du and dw and dn and dustr and dwstr and dnstr functions.

FUNCTIONS

dustr

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.

du

Dump the result of dustr function to STDERR.

dwstr

Encode all strings in reference data to cp932 and dump the reference data to STDERR 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.

dw

Dump the result of dwstr function to STDERR.

dnstr

Dump reference data to STDERR without encoding 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.

dn

Dump the result of dnstr function to STDERR.

Bug Report

https://github.com/YoshiyukiItoh/D

SEE ALSO

Data::Dumper, Carp, Data::Recursive::Encode

AUTHOR

Yoshiyuki Ito, <yoshiyuki.ito.biz@gmail.com>

Yuki Kimoto, <kimoto.yuki@gmail.com>

COPYRIGHT AND LICENSE

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.