Data::Grid::Row - Row implementation for Data::Grid::Table
Version 0.01_01
# CSV files are themselves only a single table, so the list # context assignment here takes the first and only one. my ($table) = Data::Grid->parse('foo.csv')->tables; while (my $row = $table->next) { my @cells = $row->cells; # or @cells = @$row; # or, if column names were supplied somehow: my %cells = $row->as_hash; # or %cells = %$row; }
Retrieve the Data::Grid::Table object to which this row belongs. Alias for "parent" in Data::Grid::Container.
Retrieve the cells from the row, as an array in list context or arrayref in scalar context. The array dereferencing operator @{} is also overloaded and works like this:
@{}
my @cells = @$row;
If the table has a heading or its columns were designated in the constructor or with "columns" in Data::Grid::Table, this method will return the row as key-value pairs in list context and a HASH reference in scalar context. If there is no column spec, this method will generate dummy column names starting from 1, like col1, col2, etc. It will also fill in the blanks if the column spec is shorter than the actual row. If the column spec is longer, the overhang will be populated with undefs. As well it is worth noting that duplicate keys will be clobbered with the rightmost value at this time, though that behaviour may change. As with the other pertinent methods, the hash dereference operator %{} is overloaded and will behave as such:
col1
col2
undef
%{}
my %cells = %$row;
Dorian Taylor, <dorian at cpan.org>
<dorian at cpan.org>
Please report any bugs or feature requests to bug-data-grid at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Grid. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-data-grid at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Data::Grid::Row
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-Grid
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Data-Grid
CPAN Ratings
http://cpanratings.perl.org/d/Data-Grid
Search CPAN
http://search.cpan.org/dist/Data-Grid/
Data::Grid, Data::Grid::Container, Data::Grid::Table, Data::Grid::Cell
Copyright 2010 Dorian Taylor.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Data::Grid, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Grid
CPAN shell
perl -MCPAN -e shell install Data::Grid
For more information on module installation, please visit the detailed CPAN module installation guide.