View on
MetaCPAN
Dorian Taylor > Data-Grid-0.01_01 > Data::Grid::Row

Download:
Data-Grid-0.01_01.tar.gz

Dependencies

Annotate this POD

Module Version: 0.01_01   Source  

NAME ^

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

VERSION ^

Version 0.01_01

SYNOPSIS ^

    # 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;
    }

METHODS ^

table

Retrieve the Data::Grid::Table object to which this row belongs. Alias for "parent" in Data::Grid::Container.

cells

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;

as_hash

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:

    my %cells = %$row;

AUTHOR ^

Dorian Taylor, <dorian at cpan.org>

BUGS ^

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.

SUPPORT ^

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

    perldoc Data::Grid::Row

You can also look for information at:

SEE ALSO ^

Data::Grid, Data::Grid::Container, Data::Grid::Table, Data::Grid::Cell

LICENSE AND COPYRIGHT ^

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.

syntax highlighting: