Full-Duplex Communications

Engineered Telecommunications Solutions

Download Text::Report - Version 1.004

NAME

Text::Report - Perl extension for generating mixed columnar formatted reports and report templates

VERSION

Version 1.004

SYNOPSIS

    use Text::Report;

    # Let's build a simple report complete with title lines, footer
    # and two disparate data sets in tabular form

    # Create a new report object:
    $rpt = Text::Report->new(debug => 'error', debugv => 1);


    # Create a title block:
    $rpt->defblock(name => 'title_lines');

    # Create a separator:
    $rpt->insert('dbl_line');

    # Create a data block:
    $rpt->defblock(name => 'data1',
          title => 'Statistical Analysis Of Gopher Phlegm Over Time',
          useColHeaders => 1,
          sortby => 1,
          sorttype => 'alpha',
          orderby => 'ascending',
          columnWidth => 14,
          columnAlign => 'left',
          pad => {top => 2, bottom => 2},);

    # Create another data block:
    $rpt->defblock(name => 'data2',
          title => 'Resultant Amalgamum Firnunciation Per Anum',
          useColHeaders => 1,
          sortby => 1,
          sorttype => 'numeric',
          orderby => 'ascending',
          columnWidth => 10,
          columnAlign => 'right',
          pad => {top => 2, bottom => 2},);

    # Create a separator:
    $rpt->insert('dotted_line');

    # Create a footer block:
    $rpt->defblock(name => 'footer');

    # Add column headers:
    @header = qw(gopher_a gopher_b gopher_c bobs_pudding);
    @header2 = qw(avg mean meaner meanest outraged paralyzed);

    $i = 0;
    for(@header){$rpt->setcol('data1', ++$i, head => $_);}

    $i = 0;
    for(@header2){$rpt->setcol('data2', ++$i, head => $_);}

    # Change column settings for 'bobs_pudding' data:
    $rpt->setcol('data1', 4, align => 'right', width => 16);

    @data = (
       ['a1', 'a2', 'a3', 'b4'],
       ['b1', 'b2', 'b3', 'c4'],
       ['c1', 'c2', 'c3', 'c4'],);

    @data2 = (
       ['562.93', '121.87', '53.95', '46.05', '39.00', '129.00'],
       ['123.62', '191.25', '14.62', '52.58', '63.14', '256.32'],);

    # Fill our blocks with some useful data:
    $rpt->fill_block('title_lines', ['Simple Report'], ['Baltimore Zoological Research Lab']);
    $rpt->fill_block('data1', @data);
    $rpt->fill_block('data2', @data2);
    $rpt->fill_block('footer', ['Acme Cardboard - All Rights Reserved'], ['Apache Junction, Arizona']);

    # Get our formatted report:
    @report = $rpt->report('get');

    # Print report:
    for(@report){print $_, "\n";}



                                     Simple Report
                           Baltimore Zoological Research Lab

   ================================================================================



   STATISTICAL ANALYSIS OF GOPHER PHLEGM OVER TIME
   -----------------------------------------------

   gopher_a        gopher_b        gopher_c             bobs_pudding
   ______________  ______________  ______________   ________________
   a1              a2              a3                             b4
   b1              b2              b3                             c4
   c1              c2              c3                             c4




   RESULTANT AMALGAMUM FIRNUNCIATION PER ANUM
   ------------------------------------------

           avg        mean      meaner     meanest    outraged   paralyzed
    __________  __________  __________  __________  __________  __________
        123.62      191.25       14.62       52.58       63.14      256.32
        562.93      121.87       53.95       46.05       39.00      129.00


   ................................................................................

                         Acme Cardboard - All Rights Reserved
                               Apache Junction, Arizona




   Beautiful isn't it. And the coolest thing...
      You can save the report template and use it over and over and over...


DESCRIPTION

Being a Practical Reporting language, it only seems fitting that one should be able to generate nicely formatted reports with Perl without ever having to do this stuff (and worse)

   format =
   @<<<<<<<<<<<<<<<<  @<<<<<<<<<<<<<<<  @||||||||||| @>>>>> $@###.##
   $bla, $foo, $blek, $bar, $gnu
   .

over and over again.

And clearing accumulators and writing vast amounts of polemic, convoluted code and cursing. And slamming doors and kicking things that bark and meow. And eventually, while sobbing uncontrollably, copying and pasting the stuff into a spreadsheet at 3:30 A.M.. I have seen this. Ugly stuff. Gives me the creeps.

Well guess what? This type of aberrant behavior will soon be a thing of the past. You may even tear page 168 out of your (2nd edition) Camel Book now. Sure, go ahead. What, it's not your book? Ahh, do it anyway. Whoever does own it will thank you. Unless it's a library book. Then you've got problems.

With Text::Report you can create beautiful text based reports on the fly and even collect csv data for retrieval just in case you still have some primal urge to do the spreadsheet thing. You will never have to touch another perl "format" function ever again.

Just initialize a new report object, tweak the global settings to your liking, create page title and footer blocks, some separators, and data blocks (tabular data) to your heart's content. When you're done building you can save the report template to be used later for the same type of report or you can begin stuffing table data into your data blocks. And that's it. You can now print the report or write it to a file.

Text::Report will very likely get you so excited that you will mistakenly phone up family members and try to explain it to them.

METHODS

MISCELLANEOUS METHODS

EXAMPLES

TODO

Page breaks and pagination. I originally developed Text::Report for electronic media and really had no need to introduce the added overhead and complexity of page numbering, order and vertical sizing. I have used Text::Report in a line-printer environment and everything looks great, however paginating for precut paper presents issues. The need to laser print, at least for me and those who I know are using this package, has not yet presented itself.

I tell you this only so that you know that I know that Text::Report is lacking a bit in the hardcopy print arena.

BUGS

None that I'm aware of at the moment, but as sure as The Sun Also Rises, someone, perhaps soon, will discover what I will call "some new features". Some features may require adjustments. Some features may require removal. I am preparing myself for the inevitable.

You may report any bugs or feature requests to bug-text-report at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Text-Report. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Text::Report

You can also look for information at:

ACKNOWLEDGEMENTS

SEE ALSO

CPAN - Latest Text::Report on CPAN, Search CPAN

AUTHOR

David Huggins, (davidius AT cpan DOT org), http://www.full-duplex.com, http://www.in-brandon.com

COPYRIGHT AND LICENSE

Copyright (C) 2007 by Full-Duplex Communications, Inc. All rights reserved.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

If you need a copy of the GNU General Public License write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA