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

NAME

Iterator::BreakOn::Base - Base class for iterator with flow breaks

SYNOPSIS

    package MyIterator;
    use qw(Iterator::BreakOn::Base);

    1;

DESCRIPTION

This module is a base class for build iterators with flow breaks. Provides methods for create and proccess the iterators.

SUBROUTINES/METHODS

new( )

This method create a new package object. The parameters are:

  • datasource

    Object reference with a next method supported. That method return a data object with a get method for read the values.

  • getmethod

    This is the method name for read individual values. The default value is get in Base module and 'get_column' in this module.

  • private

    Reference to arbitrary data to save in the object. Useful for later recover his value through private method.

The following atributes can be a list of fields followed for an optional code reference. The order of the fields is significant.

  • break_before

  • break_after

These attributes must contain a code reference.

  • on_first

  • on_last

  • on_every

init( )

This method initialize the object attributes.

reset( )

This method reset the event queue of the object.

run( )

    $iter->run();

        

next( )

    while (my $item_ref = $iter->next()) {
        # do something ...
    }

This method returns the next item in the data source after process the other events in the queue.

next_event( )

    while (my $event = $iter->next_event()) {
        if ($event->name() eq 'on_last') {
            # end of data reached
            ...
        }
        ...
    }

This method return the next event in the data source. For each item readed the event name is 'on_every'.

The event is an object with the following attributes:

name

The event name can be on_first, on_last, on_every, before_XXXX or after_XXXX.

field

This is the field name if the event is before or after.

value

Field value when the event was raised.

item( )

Returns a reference to the current item in the iterator.

current_values( )

Calls to the optional getall method on the current item in the iterator, and returns a hash with fields and values.

private( )

Returns a reference to the private data save in the object.

DIAGNOSTICS

A list of every error and warning message that the module can generate.

CONFIGURATION AND ENVIRONMENT

A full explanation of any configuration system(s) used by the module, including the names and locations of any configuration files, and the meaning of any environment variables or properties that can be set. These descriptions must also include details of any configuration language used.

DEPENDENCIES

A list of all the other modules that this module relies upon, including any restrictions on versions, and an indication of whether these required modules are part of the standard Perl distribution, part of the module's distribution, or must be installed separately.

INCOMPATIBILITIES

A list of any modules that this module cannot be used in conjunction with. This may be due to name conflicts in the interface, or competition for system or program resources, or due to internal limitations of Perl (for example, many modules that use source code filters are mutually incompatible).

BUGS AND LIMITATIONS

There are no known bugs in this module. Please report problems to the author. Patches are welcome.

AUTHOR

Víctor Moral <victor@taquiones.net>

LICENSE AND COPYRIGHT

Copyright (c) 2007 - Victor Moral

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 647:

Non-ASCII character seen before =encoding in 'Víctor'. Assuming UTF-8