Index

The following methods will be exported by the :all tag: END push @d, ""$_"" for sort keys %methodParms; # Alphabetic listing of methods push @d, "\n"; writeFile("doc.data", join "\n", @d); # Write documentation file writeFile("methods.data", join "\n", sort keys %methods); # Write methods file }

#------------------------------------------------------------------------------- # Examples #-------------------------------------------------------------------------------

if (0 and !caller) {say STDERR "\n","\nsay STDERR formatTable(",dump($_), ");\n# ", formatTable($_) =~ s/\n/\n# /gr for [[qw(. aa bb cc)], [qw(1 A B C)], [qw(2 AA BB CC)], [qw(3 AAA BBB CCC)], [qw(4 1 22 333)]], [{aa=>'A', bb=>'B', cc=>'C'}, {aa=>'AA', bb=>'BB', cc=>'CC'}, {aa=>'AAA', bb=>'BBB', cc=>'CCC'}, {aa=>'1', bb=>'22', cc=>'333'}], {''=>[qw(aa bb cc)], 1=>[qw(A B C)], 22=>[qw(AA BB CC)], 333=>[qw(AAA BBB CCC)], 4444=>[qw(1 22 333)]}, {a=>{aa=>'A', bb=>'B', cc=>'C'}, aa=>{aa=>'AA', bb=>'BB', cc=>'CC'}, aaa=>{aa=>'AAA', bb=>'BBB', cc=>'CCC'}, aaaa=>{aa=>'1', bb=>'22', cc=>'333'}}, [qw(a bb ccc 4444)], {aa=>'A', bb=>'B', cc=>'C'}; }

#------------------------------------------------------------------------------- # Test #-------------------------------------------------------------------------------

sub test {eval join('', <Data::Table::Text::DATA>) || die $@ }

test unless caller();

# Documentation #extractDocumentation unless caller;

#------------------------------------------------------------------------------- # Export #-------------------------------------------------------------------------------

require Exporter;

use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

@ISA = qw(Exporter); @EXPORT = qw(formatTable); @EXPORT_OK = qw(checkKeys containingPowerOfTwo dateStamp dateTimeStamp extractDocumentation fileList fileSize formatTableBasic genLValueArrayMethods genLValueHashMethods genLValueScalarMethods genLValueScalarMethodsWithDefaultValues indentString loadArrayArrayFromLines loadArrayFromLines loadHashArrayFromLines loadHashFromLines makePath nws powerOfTwo readBinaryFile readFile saveToS3 timeStamp trim writeBinaryFile writeFile); %EXPORT_TAGS = (all=>[@EXPORT, @EXPORT_OK]);

1;

Name

Data::Table::Text - Write data in tabular text format

Synopsis

use Data::Table::Text;

say STDERR formatTable([
  [".", "aa", "bb", "cc"],
  [1, "A", "B", "C"],
  [2, "AA", "BB", "CC"],
  [3, "AAA", "BBB", "CCC"],
  [4, 1, 22, 333]]);

#    .  aa   bb   cc
# 1  1  A    B    C
# 2  2  AA   BB   CC
# 3  3  AAA  BBB  CCC
# 4  4    1   22  333


say STDERR formatTable([
  { aa => "A", bb => "B", cc => "C" },
  { aa => "AA", bb => "BB", cc => "CC" },
  { aa => "AAA", bb => "BBB", cc => "CCC" },
  { aa => 1, bb => 22, cc => 333 }]);

#    aa   bb   cc
# 1  A    B    C
# 2  AA   BB   CC
# 3  AAA  BBB  CCC
# 4    1   22  333


say STDERR formatTable({
  "" => ["aa", "bb", "cc"],
  "1" => ["A", "B", "C"],
  "22" => ["AA", "BB", "CC"],
  "333" => ["AAA", "BBB", "CCC"],
  "4444" => [1, 22, 333]});

#       aa   bb   cc
#    1  A    B    C
#   22  AA   BB   CC
#  333  AAA  BBB  CCC
# 4444    1   22  333


say STDERR formatTable({
  a => { aa => "A", bb => "B", cc => "C" },
  aa => { aa => "AA", bb => "BB", cc => "CC" },
  aaa => { aa => "AAA", bb => "BBB", cc => "CCC" },
  aaaa => { aa => 1, bb => 22, cc => 333 }});
#       aa   bb   cc
# a     A    B    C
# aa    AA   BB   CC
# aaa   AAA  BBB  CCC
# aaaa    1   22  333


say STDERR formatTable(["a", "bb", "ccc", 4444]);
# 0  a
# 1  bb
# 2  ccc
# 3  4444


say STDERR formatTable({ aa => "A", bb => "B", cc => "C" });
# aa  A
# bb  B
# cc  C

Description

Prints an array or a hash or an array of arrays or an array of hashes or a
hash of arrays or a hash of hashes in a tabular format that is easier to read
than a raw data dump.

Installation

Standard Module::Build process for building and installing modules:

perl Build.PL
./Build
./Build test
./Build install

Author

philiprbrenan@gmail.com

http://www.appaapps.com

Copyright

Copyright (c) 2016 Philip R Brenan.

This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.