Data::Tabulate - Table generation!


Data-Tabulate documentation  | view source Contained in the Data-Tabulate distribution.

Index


NAME

Top

Data::Tabulate - Table generation!

VERSION

Top

Version 0.06

SYNOPSIS

Top

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).

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 = qw(1..12);

    my $foo   = Data::Tabulate->new();
    my @table = $foo->tabulate(@array);

    my $html  = $foo->render('HTMLTable',@array);

METHODS

Top

new

create a new object of Data::Tabulate.

render ( $plugin, {data => \@array [, attr => {%hash}]} )

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:

  <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>&nbsp;</td><td>&nbsp;</td></tr>
  </table>

You can write your own plugins.

tabulate( @array )

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 ],
    )

fill_with

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

cols

returns the number of columns the table has

rows

returns the number of rows the table has

max_columns

set how many columns the table can have (at most).

    $tabulator->max_columns(3);

the table has at most three columns

min_columns

set how many columns the table can have (at least).

    $tabulator->min_columns(3);

the table has at least three columns

do_func($module, $method, @params)

If you need to call some methods of the rendering object, you can use this method, to prepare these method calls.

reset_func( $module )

reset the method call preperations

AUTHOR

Top

Renee Baecker, <module at renee-baecker.de>

BUGS

Top

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-Tabulate. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Data::Tabulate

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Data-Tabulate

* CPAN Ratings

http://cpanratings.perl.org/d/Data-Tabulate

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-Tabulate

* Search CPAN

http://search.cpan.org/dist/Data-Tabulate

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Data-Tabulate documentation  | view source Contained in the Data-Tabulate distribution.