Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Data::Format::Pretty::Console 0.18

    Download button

    No screenshots available
    Downloads: 86  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Steven Haryanto | More programs
    Perl Artistic License / FREE
    September 23rd, 2012, 03:14 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Data::Format::Pretty::Console description

    Pretty-print data structure for console output

    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.

    SYNOPSIS

    In your program:

     use Data::Format::Pretty::Console qw(format_pretty);
     ...
     print format_pretty($result);


    Some example output:

    Scalar, format_pretty("foo"):

     foo

    List, format_pretty([qw/foo bar baz qux/]):

     +------+
     | foo |
     | bar |
     | baz |
     | qux |
     '------'


    The same list, when program output is being piped (that is, (-t STDOUT) is false):

     foo
     bar
     baz
     qux


    Hash, 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, undef] ]):

     +---------+---------+---------+
     | 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=>1, b=>2}, {b=>2, c=>3}, {c=>4} ]):

     .-----------.
     | a | b | c |
     +---+---+---+
     | 1 | 2 | |
     | | 2 | 3 |
     | | | 4 |
     '---+---+---'


    Some more complex data, format_pretty({summary => "Blah...", users => [{name=>"budi", domains=>["foo.com", "bar.com"], quota=>"1000"}, {name=>"arif", domains=>["baz.com"], quota=>"2000"}], verified => 0}):

     summary:
     Blah...

     users:
     .---------------------------------.
     | domains | name | quota |
     +------------------+------+-------+
     | foo.com, bar.com | budi | 1000 |
     | baz.com | arif | 2000 |
     '------------------+------+-------'

     verified:
     0


    Structures which can't be handled yet will simply be output as YAML, format_pretty({a {b=>1}}):

     ---
     a:
     b: 1



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    data structure | Perl module | Perl | data | structure

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM