Rechercher une page de manuel
Sprog::Mixin::InputFromFH.3pm
Langue: en
Version: 2005-07-27 (fedora - 01/12/10)
Section: 3 (Bibliothèques de fonctions)
NAME
Sprog::Mixin::InputFromFH - a 'mixin' class for gears reading input from a file handleSYNOPSIS
use base qw( Sprog::Mixin::InputFromFH Sprog::Gear ); sub engage { my($self) = @_; my $fh = $self->_open_file or return; $self->fh_in($fh); return $self->SUPER::engage; }
DESCRIPTION
This mixin is for use by gears which need to read from a file handle (ie: files, pipes, sockets ...). It provides the appropriate links into the event loop to read using non-blocking IO and to pass the data read from the file handle to the next gear as a "data" message.METHODS
fh_in ( filehandle )
The gear class is responsible for opening the file handle and then passing it to this method to make it available to the other methods in this class.send_data ( )
The machine will call this method when it needs more data. The default implementation will set up an IO watch event waiting for data to arrive on the filehandle in "fh_in". When the data arrives, it will be sent as a "data" message using the gear's "msg_out" method - which you can override if you need to mess with the data.When the EOF is reached, the IO watch event handler will call the gear's "disengage" method to remove it from the geartrain.
COPYRIGHT
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.
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre