Data::TableReader::Iterator(3pm) | User Contributed Perl Documentation | Data::TableReader::Iterator(3pm) |
Data::TableReader::Iterator - Base class for iterators (blessed coderefs)
version 0.011
my $iter= $record_reader->iterator; while (my $rec= $iter->()) { ... my $position= $iter->tell; print "Marking position $position"; # position stringifies to human-readable ... $iter->seek($position); } if ($iter->next_dataset) { # iterate some more while ($rec= $iter->()) { ... printf "Have processed %3d %% of the file", $iter->progress*100; } }
This is the abstract base class for iterators used in Data::TableReader, which are blessed coderefs that return records on each call.
The coderef should support a single argument of a "slice" to extract from the record, in case not all of the record is needed.
Return a human-readable string describing the current location within the source file. This will be something like "$filename row $row" or "$filename $worksheet:$cell_id".
An estimate of how much of the data has already been returned. If the stream is not seekable this may return undef.
$iter= Data::TableReader::Iterator->new( \&coderef, \%fields );
The iterator is a blessed coderef. The first argument is the coderef to be blessed, and the second argument is the magic hashref of fields to be made available as "$iter->_fields".
If seeking is supported, this will return some value that can be passed to seek to come back to this point in the stream. This value will always be true. If seeking is not supported this will return undef.
$iter->seek($pos);
Seek to a point previously reported by "tell". If seeking is not supported this will die. If $pos is any false value it means to seek to the start of the stream.
If a file format supports more than one tabular group of data, this method allows you to jump to the next.
Michael Conrad <mike@nrdvana.net>
This software is copyright (c) 2019 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2022-06-30 | perl v5.34.0 |