NAME
Data::PrintUtils - The great new Data::PrintUtils!
VERSION
Version 0.02
SYNOPSIS
Provides a collection of pretty print routines
EXPORT
A list of functions that can be exported. You can delete this section if you don't export anything, such as for a purely object-oriented module.
SUBROUTINES/METHODS
formatList
formatOneLineHash
formatHash
formatTable
pivotTable
joinTable
print_pid
A replacement for print that will optionally prepend the processID and the timestamp to a line
These two fields are turned off/on with the package variables:
$Data::PrintUtils::USE_PIDS = 1 or 0;
$Data::PrintUtils::USE_TIME = 1 or 0;
say_pid
A replacement for say that will optionally prepend the processID and the timestamp to a line
These two fields are turned off/on with the package variables:
$Data::PrintUtils::USE_PIDS = 1 or 0;
$Data::PrintUtils::USE_TIME = 1 or 0;
formatList
Formats a list as a single line of comma seperated values in '(' ')'
formatOneLineHash
Formats a hash as a single line of => and comma separated values in '{' '}'
formatHash
formatTable
Formats a table (given as an array of hash references (as returned from DBI) ) into a somewhat pleasant display. With the Columns argument, you can chose to only print a subset of the columns (and you can define the column ordering).
- ROWS This is a reference to the table (which should be an array of hashes refs)
- COLUMNS This is a list of columns (in order) to be displayed
- UNDEF_VALUE This is a string value to be displayed whenever an item is "undefined"
pivotTable
pivots an attribute-value table (given as an array of hash references (as returned from DBI) ) into a new table with a row for each unique PIVOT_KEY and a column for each attribute
example: my @table = ( {COL1 => 1, Name => 'PID', VALUE => '1a', XTRA1 => '111'}, {COL1 => 1, Name => 'SID', VALUE => 's1', XTRA1 => '112'}, {COL1 => 1, Name => 'XV1', VALUE => 'YY', XTRA1 => '116'}, {COL1 => 1, Name => 'XV2', VALUE => 'XX', XTRA1 => '117'},
{COL1 => 2, Name => 'PID', VALUE => '2a', XTRA1 => '221'}, {COL1 => 2, Name => 'SID', VALUE => 's2', XTRA1 => '222'}, {COL1 => 2, Name => 'XV2', VALUE => 'XX2', XTRA1 => '224'}, ); my @newTable1 = pivotTable { ROWS => \@table, PIVOT_KEY => 'COL1', VALUE_HEADER_KEY=> 'Name', VALUE_KEY => 'VALUE'}; say formatTable { ROWS => \@newTable1, UNDEF_VALUE => 'NULL'} if @newTable1;
results in COL1 PID SID XV1 XV2 1 1a s1 YY XX 2 2a s2 NULL XX2
joinTable
Formats a table (given as an array of hash references (as returned from DBI) ) into a somewhat pleasant display. With the Columns argument, you can chose to only print a subset of the columns (and you can define the column ordering).
AUTHOR
Robert Haxton, <robert.haxton at gmail.com>
BUGS
Please report any bugs or feature requests to bug-Data-printutils at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-PrintUtils. 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 Data::PrintUtils
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2008-2011 Robert Haxton.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.