The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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)

Constructor method. A reference to a list of values is passed as the first parameter and subsequent get_first() and get_next() calls will return each element.

get_first()

Returns a ($value, $error) pair for the first item in the iterator set. The $error returned may be zero or undefined to indicate a valid datum was successfully returned. Returns an error of STATUS_DONE if the list is empty.

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

get_all()

Returns a (\@values, $error) pair for all remaining items in the iterator set. Returns an error of STATUS_DONE if all items in the list have been visited.

size(), max(), index(), number(), first(), last()

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.

AUTHOR

Andy Wardley <abw@kfs.org>

    http://www.template-toolkit.org/
    http://www.kfs.org/~abw/

REVISION

$Revision: 1.1 $

COPYRIGHT

    Copyright (C) 1996-2000 Andy Wardley.  All Rights Reserved.
    Copyright (C) 1998-2000 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.

SEE ALSO

Template