- PUBLIC METHODS
- SEE ALSO
Template::Iterator - Base iterator class used by the FOREACH directive.
my $iter = Template::Iterator->new(\@data, \%options);
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.
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:
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'.
A code ref to be called on each iteration. The data item is passed. The modified data should be returned.
Returns a ($value, $error) pair for the first item in the iterator set. Returns an error of STATUS_DONE if the list is empty.
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.
Return the size of the iteration set, the maximum index number (size - 1), the current index number (0..max), the iteration number offset from 1 (index + 1, i.e. 1..size), and boolean values indicating if the current iteration is the first or last in the set, respectively.
Andy Wardley <cre.canon.co.uk>
$Revision: 1.8 $
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.