
Data::Tabulator - Create a table (two-dimensional array) from a list (one-dimensional array)

Version 0.03

my $table = Data::Tabulator->new([ 'a' .. 'z' ], rows => 6);
my $rows = $table->rows;
# Returns a the following two-dimensional array:
# [
# [ qw/ a b c d e / ],
# [ qw/ f g h i j / ],
# [ qw/ k l m n o / ],
# [ qw/ p q r s t / ],
# [ qw/ u v w x y / ],
# [ qw/ z/ ],
# ]
my $columns = $table->columns;
# Returns a the following two-dimensional array:
# [
# [ qw/ a f k p u z / ],
# [ qw/ b g l q v / ],
# [ qw/ c h m r w / ],
# [ qw/ d i n s x / ],
# [ qw/ e j o t y / ],
# ]

Data::Tabulator is a simple and straightforward module for generating a table from an array. It can properly handle data that is in either row- or column-major order.

Extracts and returns the rows of the array.
A shortcut to ->new, see Data::Tabulator->new for parameter specification and more information.
Extracts and returns the columns of the array.
A shortcut to ->new, see Data::Tabulator->new for parameter specification and more information.

The first argument to new may be an array (a list reference). Alternatively, you can pass in the array via the "data" parameter.
The following parameters are also accepted:
data => The array (list reference) to turn into a table.
rows => The number of rows the table should have.
columns => The number of columns the table should have.
pad => A true/false indicator on whether to pad if the array is not long enough. The default is not to pad.
padding => The padding data to use if the array is not long enough (not a full M x N table). The default is undef.
row_major => A true value indicates that the array data is in row-major order. This is the default.
column_major => A true value indicates that the array data is in column-major order.
Note: passing in "padding" and not specifying the "pad" option will automatically turn "pad" on.
Return a reference to the underlying array of the table.
Alternatively, make $table use the specified <array>.
When setting $table->data, make sure you're passing in a list reference.
Return the width of the table (the number of columns).
Return the height of the table (the number of rows).
Return the width and height of the table.
In scalar context, this will return a two-element array.
my ($width, $height) = $table->geometry;
my $geometry = $table->geometry;
$width = $geometry->[0];
$height = $geometry->[1];
Toggle padding on/off.
Set the padding data to use.
Return true if the data for $table is in row-major order.
Return true if the data for $table is in column-major order.
Return an array of rows in the table.
Set the number of rows in the table to <count>. This is equivalent to passing in row_count to the new method. As a side effect, this will change the number of columns in table.
Does not return anything.
Return an array of columns in the table.
Set the number of columns in the table to <count>. This is equivalent to passing in column_count to the new method. As a side effect, this will change the number of rows in table.
Does not return anything.
Return row <i>
<i> should be a number from 0 to $tables->rows - 1
Return column <j>
<j> should be a number from 0 to $tables->columns - 1
Return the table as a simple string.
By default, rows are separated by "\n" and columns are separated by " ".


Robert Krimen, <rkrimen at cpan.org>

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

You can find documentation for this module with the perldoc command.
perldoc Data::Tabulator
You can also look for information at:


Copyright 2007 Robert Krimen, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.