Data::Format::Pretty::Console

Pretty-print data structure for console output
Download

Data::Format::Pretty::Console Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Steven Haryanto
  • Publisher web site:
  • http://search.cpan.org/~sharyanto/

Data::Format::Pretty::Console Tags


Data::Format::Pretty::Console Description

Data::Format::Pretty::Console is a Perl module meant to output data structure in a "pretty" or "nice" format, suitable for console programs. The idea of this module is that for you to just merrily dump data structure to the console, and this module will figure out how to best display your data to the end-user.Currently this module tries to display the data mostly as a nice ASCII table (or a series of ASCII tables), and failing that, display it as YAML.This module takes piping into consideration, and will output a simpler, more suitable format when your user pipes your program's output into some other program.Most of the time, you don't have to configure anything, but some options are provided to tweak the output.This module uses Log::Any for logging.SYNOPSISIn your program: use Data::Format::Pretty::Console qw(format_pretty); ... print format_pretty($result);Some example output:Scalar, format_pretty("foo"): fooList, format_pretty(): +------+ | foo | | bar | | baz | | qux | '------'The same list, when program output is being piped (that is, (-t STDOUT) is false): foo bar baz quxHash, format_pretty({foo=>"data",bar=>"format",baz=>"pretty",qux=>"console"}): +-----+---------+ | bar | format | | baz | pretty | | foo | data | | qux | console | '-----+---------'2-dimensional array, format_pretty(, , ]): +---------+---------+---------+ | 1 | 2 | | | 28 | bar | 3 | | foo | 3 | | '---------+---------+---------'An array of hashrefs, such as commonly found if you use DBI's fetchrow_hashref() and friends, format_pretty(): .-----------. | a | b | c | +---+---+---+ | 1 | 2 | | | | 2 | 3 | | | | 4 | '---+---+---'Some more complex data, format_pretty({summary => "Blah...", users => , quota=>"1000"}, {name=>"arif", domains=>, quota=>"2000"}], verified => 0}): summary: Blah... users: .---------------------------------. | domains | name | quota | +------------------+------+-------+ | foo.com, bar.com | budi | 1000 | | baz.com | arif | 2000 | '------------------+------+-------' verified: 0Structures which can't be handled yet will simply be output as YAML, format_pretty({a {b=>1}}): --- a: b: 1Product's homepage


Data::Format::Pretty::Console Related Software