NAME
Template::Iterator - Base iterator class used by the FOREACH directive.
SYNOPSIS
my $iter = Template::Iterator->new(\@data, \%options);
DESCRIPTION
THe Template::Iterator module defines a generic data iterator for use by the FOREACH directive.
It may be used as the base class for custom iterators.
PUBLIC METHODS
new(\@data, \%options)
Constructor method. A reference to a list of values is passed as the first parameter and subsequent first() and next() calls will return each element.
The second optional parameter may be a hash reference containing the following items:
- ORDER
-
A code reference which will be called to pre-sort the data items. A list reference is passed in and should be returned, along with any status code. The ORDER option may also be either of the strings 'sorted' or 'reverse'.
- ACTION
-
A code ref to be called on each iteration. The data item is passed. The modified data should be returned.
first()
Returns a ($value, $error) pair for the first item in the iterator set. Returns an error of STATUS_DONE if the list is empty.
next()
Returns a ($value, $error) pair for the next item in the iterator set. Returns an error of STATUS_DONE if all items in the list have been visited.
AUTHOR
Andy Wardley <cre.canon.co.uk>
REVISION
$Revision: 1.5 $
COPYRIGHT
Copyright (C) 1996-1999 Andy Wardley. All Rights Reserved. Copyright (C) 1998-1999 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.