Data::Tabulate - Table generation!
version 0.09
Data::Tabulate aims to simplify the generation of tables. Often you don't have tables like in databases (with header and several rows of data), but tables with content only (like image galleries or listings displayed as tables).
Data::Tabulate
You can use other modules (e.g. HTML::Table) to produce specific output.
Perhaps a little code snippet.
use Data::Tabulate; use Data::Dumper; my @array = (1..12); my $foo = Data::Tabulate->new(); my $html1 = $foo->render('HTMLTable', { data => \@array }); @array = ( 13 .. 24 ); my @table = $foo->tabulate(@array); my $html2 = $foo->render('HTMLTable'); print Dumper({ 'html with raw array data' => $html1, 'html with tabulate data' => $html2, });
create a new object of Data::Tabulate.
This methods loads the Plugin $plugin and renders the table with the plugin.
Example:
my $html_table = $tabulator->render('HTMLTable',{data => [1..10]});
loads the module Data::Tabulate::Plugin::HTMLTable and returns this string:
Data::Tabulate::Plugin::HTMLTable
<table> <tr><td>1</td><td>2</td><td>3</td></tr> <tr><td>4</td><td>5</td><td>6</td></tr> <tr><td>7</td><td>8</td><td>9</td></tr> <tr><td>10</td><td> </td><td> </td></tr> </table>
You can write your own plugins.
This methods creates an array of arrays that can be used to render a table or you can do your own thing with the array.
my @array = $tabulator->tabulate(1..10);
returns
( [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ], [10, undef, undef ], )
if the array doesn't provide enough elements the table is filled with 'undef' elements sometimes this is not the wanted behaviour. So you can change the value that is used to fill the array.
$obj->fill_with( 'hi' );
for an example see t/04_fill_with.t
returns the number of columns the table has
returns the number of rows the table has
set how many columns the table can have (at most).
$tabulator->max_columns(3);
the table has at most three columns
set how many columns the table can have (at least).
$tabulator->min_columns(3);
the table has at least three columns
If you need to call some methods of the rendering object, you can use this method, to prepare these method calls.
reset the method call preperations
Renee Baecker <module@renee-baecker.de>
This software is Copyright (c) 2015 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Data::Tabulate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Tabulate
CPAN shell
perl -MCPAN -e shell install Data::Tabulate
For more information on module installation, please visit the detailed CPAN module installation guide.