Data::Grid::Row - Row implementation for Data::Grid::Table


Version 0.06


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

cells [$FLATTEN]

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;


Returns the width of the row in columns. This is the same as scalar @{$row->cells}.

as_hash [$FLATTEN]

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.


Returns the row as CSV, quoted where necessary, minus the newline.


Dorian Taylor, <dorian at>



Copyright 2010-2018 Dorian Taylor.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.