Data::Format::Pretty - Pretty-print data structure
version 0.04
In your program:
use Data::Format::Pretty qw(format_pretty print_pretty); # automatically choose an appropriate formatter print format_pretty($data); # explicitly select a formatter print format_pretty($data, {module=>'JSON'}); # specify formatter option(s) print format_pretty($data, {module=>'Console', interactive=>1}); # shortcut for printing to output print_pretty($data); # ppr() is alias for print_pretty(), exported automatically. suitable for when # debugging. use Data::Format::Pretty; ppr [1, 2, 3];
Data::Format::Pretty is an extremely simple framework for pretty-printing data structure. Its focus is on "prettiness" and automatic detection of appropriate format to use.
To develop a formatter, look at one of the formatter modules (like Data::Format::Pretty::JSON) for example. You only need to specify one function, format_pretty.
format_pretty
Send $data to formatter module (one of Data::Format::Pretty::* modules) and return the result. Options:
module => STR
Select the formatter module. It will be prefixed with "Data::Format::Pretty::".
Currently if unspecified the default is 'Console', or 'HTML' if CGI/PSGI/plackup environment is detected. In the future, more sophisticated detection logic will be used.
The rest of the options will be passed to the formatter module.
Just call format_pretty() and print() it.
Alias for print_pretty().
One of Data::Format::Pretty::* formatter, like Data::Format::Pretty::Console, Data::Format::Pretty::HTML, Data::Format::Pretty::JSON, Data::Format::Pretty::YAML.
Alternative data formatting framework/module family: Any::Renderer.
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2013 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::Format::Pretty, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Format::Pretty
CPAN shell
perl -MCPAN -e shell install Data::Format::Pretty
For more information on module installation, please visit the detailed CPAN module installation guide.