NAME
Text::Column - format tables from specific array and hash structures
SYNOPSIS
use Text::Column
$table = Text::Column->format_hash_table(\%hash, \@width, \@header)
$table = Text::Column->format_array_table(\@array, \@width, \@header)
DESCRIPTION
The methods in this module are used to generate formated tables from the data in various specific array and hash structures.
format_array_table method
$formated_table = Text::Column->format_array_table(\@array, \@width, \@header)
The format_array_table method provides a formatted table suitable for inclusion in a POD. The \@array variable references an array of array references. Each array reference in the top array is for a row array that contains the items in column order for the row. The \@width variable references the width of each column in column order while the \@header references the table column names in column order.
format_hash_table method
$table = Text::Column->format_hash_table(\%hash, \@width, \@header)
The format_hash_table method provides a formatted table suitable for inclusion in a POD. The \%array variable references a hash of references to either arrays or hashes. Each key is the first column of a row. An array referenced by the hash value contains the items in column order for the rest of the row. The keys of a hash referenced by the hash value is the items for the next column in the row. Any other hash value signals the end of the row. The format_hash_table method always sort hash keys.
The \@width variable references the width of each column in column order while the \@header references the table column names in column order.
REQUIREMENTS
Coming soon.
DEMONSTRATION
~~~~~~ Demonstration overview ~~~~~
Perl code begins with the prompt
=>
The selected results from executing the Perl Code follow on the next lines. For example,
=> 2 + 2
4
~~~~~~ The demonstration follows ~~~~~
=> use File::Spec;
=> use File::Package;
=> my $fp = 'File::Package';
=> my $tt = 'Text::Column';
=> my $loaded = '';
=> my $template = '';
=> my %variables = ();
=> my $expected = '';
=> my $errors = $fp->load_package($tt)
=> $errors
''
=> my @array_table = (
=> [qw(module.pm 0.01 2003/5/6 new)],
=> [qw(bin/script.pl 1.04 2003/5/5 generated)],
=> [qw(bin/script.pod 3.01 2003/6/8), 'revised 2.03']
=> );
=> $tt->format_array_table(\@array_table, [15,7,10,15],[qw(file version date comment)])
' file version date comment
--------------- ------- ---------- ---------------
module.pm 0.01 2003/5/6 new
bin/script.pl 1.04 2003/5/5 generated
bin/script.pod 3.01 2003/6/8 revised 2.03
'
=> my %hash_table = (
=> 'module.pm' => [qw(0.01 2003/5/6 new)],
=> 'bin/script.pl' => [qw(1.04 2003/5/5 generated)],
=> 'bin/script.pod' => [qw(3.01 2003/6/8), 'revised 2.03']
=> );
=> $tt->format_hash_table(\%hash_table, [15,7,10,15],[qw(file version date comment)])
' file version date comment
--------------- ------- ---------- ---------------
bin/script.pl 1.04 2003/5/5 generated
bin/script.pod 3.01 2003/6/8 revised 2.03
module.pm 0.01 2003/5/6 new
'
=> %hash_table = (
=> 'L<test1>' => {'L<requirement4>' => undef, 'L<requirement1>' => undef },
=> 'L<test2>' => {'L<requirement3>' => undef },
=> 'L<test3>' => {'L<requirement2>' => undef, 'L<requirement1>' => undef },
=> );
=> $tt->format_hash_table(\%hash_table, [20,20],[qw(test requirement)])
' test requirement
-------------------- --------------------
L<test1> L<requirement1>
L<test1> L<requirement4>
L<test2> L<requirement3>
L<test3> L<requirement1>
L<test3> L<requirement2>
'
QUALITY ASSURANCE
Running the test script 'Column.t' found in the "Text-Column-$VERSION.tar.gz" distribution file verifies the requirements for this module.
All testing software and documentation stems from the Software Test Description (STD) program module 't::Text::Column', found in the distribution file "Text-Column-$VERSION.tar.gz".
The 't::Text::Column' STD POD contains a tracebility matix between the requirements established above for this module, and the test steps identified by a 'ok' number from running the 'Column.t' test script.
The t::Text::Column' STD program module '__DATA__' section contains the data to perform the following:
to generate the test script 'Column.t'
generate the tailored STD POD in the 't::Text::Column' module,
generate the 'Column.d' demo script,
replace the POD demonstration section herein with the demo script 'Column.d' output, and
run the test script using Test::Harness with or without the verbose option,
To perform all the above, prepare and run the automation software as follows:
Install "Test_STDmaker-$VERSION.tar.gz" from one of the respositories only if it has not been installed:
http://www.softwarediamonds/packages/
http://www.perl.com/CPAN-local/authors/id/S/SO/SOFTDIA/
manually place the script tmake.pl in "Test_STDmaker-$VERSION.tar.gz' in the site operating system executable path only if it is not in the executable path
place the 't::Text::Column' at the same level in the directory struture as the directory holding the 'Text::Column' module
execute the following in any directory:
tmake -test_verbose -replace -run -pm=t::Text::Column
NOTES
FILES
The installation of the "Text-Column-$VERSION.tar.gz" distribution file installs the 'Docs::Site_SVD::Text_Column' SVD program module.
The __DATA__ data section of the 'Docs::Site_SVD::Text_Column' contains all the necessary data to generate the POD section of 'Docs::Site_SVD::Text_Column' and the "Text-Column-$VERSION.tar.gz" distribution file.
To make use of the 'Docs::Site_SVD::Text_Column' SVD program module, perform the following:
install "ExtUtils-SVDmaker-$VERSION.tar.gz" from one of the respositories only if it has not been installed:
http://www.softwarediamonds/packages/
http://www.perl.com/CPAN-local/authors/id/S/SO/SOFTDIA/
manually place the script vmake.pl in "ExtUtils-SVDmaker-$VERSION.tar.gz' in the site operating system executable path only if it is not in the executable path
Make any appropriate changes to the __DATA__ section of the 'Docs::Site_SVD::Text_Column' module. For example, any changes to 'Text::Column' will impact the at least 'Changes' field.
Execute the following:
vmake readme_html all -pm=Docs::Site_SVD::Text_Column
AUTHOR
The holder of the copyright and maintainer is
<support@SoftwareDiamonds.com>
COPYRIGHT NOTICE
Copyrighted (c) 2002 Software Diamonds
All Rights Reserved
BINDING REQUIREMENTS NOTICE
Binding requirements are indexed with the pharse 'shall[dd]' where dd is an unique number for each header section. This conforms to standard federal government practices, 490A ("3.2.3.6" in STD490A). In accordance with the License, Software Diamonds is not liable for any requirement, binding or otherwise.
LICENSE
Software Diamonds permits the redistribution and use in source and binary forms, with or without modification, provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
SOFTWARE DIAMONDS, http::www.softwarediamonds.com, PROVIDES THIS SOFTWARE 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWARE DIAMONDS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING USE OF THIS SOFTWARE, EVEN IF ADVISED OF NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE POSSIBILITY OF SUCH DAMAGE.