Вячеслав Тихановский
and 1 contributors

NAME

Text::APL::Reader - reader

DESCRIPTION

Reads a template from various sources. Accepts a subroutine for a custom implementation.

Returns a reference to subroutine. When called accepts another reference to subroutine that is called upon receiving a chunk of the template.

For example a reader from a scalar reference is implemented as:

    $reader = sub {
        my ($cb) = @_;

        $cb->(${$input_string});
        $cb->();
    };

The first call on cb notifies Text::APL about the template chunk and second without arguments notifies Text::APL about EOF.

The following sources are implemented:

    $reader->(\$scalar);
    $reader->($filename);
    $reader->($filehandle);
    $reader->(sub {...custom code...});

Custom subroutines are used for non-blocking template reading. See examples/ directory for an example using IO::AIO for non-blocking template reading.

METHODS

build

Build a reader.