TableDataRole::Spec::Basic - Required methods for all TableData::* modules
This document describes version 0.1.3 of TableDataRole::Spec::Basic (from Perl distribution TableData), released on 2021-04-11.
Usage:
my $table = TableData::Foo->new([ %args ]);
Constructor. Must accept a pair of argument names and values.
my $csv = $table->as_csv;
Must return the whole table data as CSV (string). May reset the row iterator (see "get_row_arrayref" and "reset_iterator").
my $n = $table->get_column_count;
Must return the number of columns of the table.
my @colnames = $table->get_column_names; my $colnames = $table->get_column_names;
Must return a list (or arrayref) containing the names of columns, ordered. For ease of use, when in list context the method must return a list, and in scalar context must return an arrayref.
my $arrayref = $table->get_row_arrayref;
Must return the next row of the table as arrayref: if called the first time, must return the first row; then the second, and so on. Must return undef if there are no more rows in the table.
Can be interspersed with "get_row_hashref". A call to either get_row_arrayref or get_row_hashref move the internal row iterator.
get_row_arrayref
get_row_hashref
Beware of methods that may reset the row iterator. For safety it is recommended that you call "reset_iterator" first, then get all the rows you want at one go.
See also "reset_iterator".
my $count = $table->get_row_count;
Must return the number of data rows in the table. May reset the row iterator (see "get_row_arrayref" and "reset_iterator").
my $hashref = $table->get_row_hashref;
Just like "get_row_arrayref", but must return the row as hashref instead of arrayref.
$table->reset_iterator;
Can be used to reset the iterator so the next call to "get_row_arrayref" or "get_row_hashref".
Please visit the project's homepage at https://metacpan.org/release/TableData.
Source repository is at https://github.com/perlancar/perl-Tables.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=TableData
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2021, 2020 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install TableData, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TableData
CPAN shell
perl -MCPAN -e shell install TableData
For more information on module installation, please visit the detailed CPAN module installation guide.