IO::Handle::Iterator(3pm)

IO::Handle::Iterator3pm

Iterator based read handle

Usage

    IO::Handle::Iterator->new(sub {
        return $next_line; # or undef on eof
    });

Overview

This class lets you define a read handle with a few fallback methods (like "read") using a single callback that behaves like "getline".

This is similar but much simpler than:

    IO::Handle::Prototype::Fallback->new(
        __read => sub { ... },
    );

The reason being that the IO::Handle::Prototype::Fallback implementation will try its very best to behave correctly (i.e. respect the value of $/), whereas this implementation assumes it's fine to return things that aren't exactly lines from "getline", so the values are just passed through.

Read buffering

When a method that requires buffering is invoked the handle is reblessed to a subclass which handles buffering.

Calling "getline" again on this object will return the value of the buffer and return to the normal iterator class.

Releases

7 releases since Debian 7 (Wheezy); the text changed 3 times.

  1. 7–9
  2. 10
  3. 11
  4. 12–13

From libio-handle-util-perl 0.02-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.