Sprog::Mixin::InputByPara.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::InputByPara - a 'mixin' class for gears reading input by empty line-separated paragraphs

SYNOPSIS

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

DESCRIPTION

This mixin is for use by gears which use a 'pipe' style of input connector but want to process the input blank-line-delimited paragraph-by-paragraph.

It defines a "data" method which passes each paragraph of input to the gear's "para" method.

METHODS

data ( buffer )

Extracts paragraphs from the supplied buffer and passes them to the "para" method. Paragraphs are assumed to be separated by blank lines. A line which contains only spaces is not considered a blank line.

A buffer which ends with some text that has no paragraph 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 paragraph will be passed to the gear's "para" method

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

ACKNOWLEDGEMENTS

Chris Benson had the original idea for this gear and created the initial implementation by adapting the Sprog::Mixin::InputByLine class. 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.