Sprog::Mixin::SlurpFile.3pm

Langue: en

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

Section: 3 (Bibliothèques de fonctions)

NAME

Sprog::Mixin::SlurpFile - a 'mixin' class for gears reading a file at a time

SYNOPSIS

   use base qw(
     Sprog::Mixin::SlurpFile
     Sprog::Gear
   );
 
   sub file_data {
     my($self, $data, $filename) = @_;
 
     # do stuff with $data and call $self->msg_out
   }
 
 

DESCRIPTION

This mixin is for use by gears which use a 'pipe' style of input connector but only want to process a whole file at a time. It defines a "data" method which buffers input until the "file_end" event, at which point it calls your module's "file_data" method and passes all the accumulated data.

METHODS

file_start ( filename )

Resets the buffer and then propagates the "file_start" event.

data ( chunk )

Adds the chunk of input into a buffer.

file_end ( filename )

Passes the accumulated data from the buffer to the "file_data" method and then propagates the "file_start" event.

A class that uses this mixin is expected to implement a "file_data" method. It should accept two arguments: the data and the filename.

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.