Sprog::Mixin::InputByLine.3pm

Langue: en

Autres versions - même langue

Version: 2005-07-26 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

Sprog::Mixin::InputByLine - a 'mixin' class for gears reading input line-by-line

SYNOPSIS

   use base qw(
     Sprog::Mixin::InputByLine
     Sprog::Gear
   );
 
 

DESCRIPTION

This mixin is for use by gears which use a 'pipe' style of input connector but want to process the input line-by-line. It defines a "data" method which passes each line of input to the gear's "line" method.

METHODS

data ( buffer )

Extracts lines from the supplied buffer and passes them to the "line" method. A buffer which ends with some text that has no line terminator, will be handled as follows:
*
if there are no more messages queued, the remaining text is re-queued until a subsequent message is received
*
if the next queued message is also a "data" message, the remaining text will be prepended to the next buffer
*
otherwise (if the next message is not a "data" message), the incomplete line will be passed to the gear's "line" method

A class that uses this mixin is expected to implement a "line" method.

Copyright 2005 Grant McLean <grantm@cpan.org>

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