Mojo::IOLoop::LineReader
version 0.3
use Mojo::IOLoop::LineReader; # Create reader my $reader = Mojo::IOLoop::LineReader->new($handle); $reader->on(readln => sub { my ($reader, $line) = @_; ... }); $reader->on(close => sub { my $reader = shift; ... }); $reader->on(error => sub { my ($reader, $err) = @_; ... }); # Start and stop watching for new data $reader->start; $reader->stop; # Start reactor if necessary $reader->reactor->start unless $reader->reactor->is_running;
Mojo::IOLoop::LineReader is a subclass of Mojo::IOLoop::Stream that implements reading from a handle line by line.
Mojo::IOLoop::LineReader - Non-blocking line-oriented input stream
Mojo::IOLoop::LineReader inherits all events from Mojo::IOLoop::Stream and can emit the following new ones.
$reader->on(readln => sub { my ($reader, $line) = @_; ... });
When data arrives on the stream, it is broken down into lines. This event is emitted for each such line.
Mojo::IOLoop::LineReader inherits all attributes from Mojo::IOLoop::Stream and implements the following new ones.
my $rs = $reader->input_record_separator; $reader = $reader->input_record_separator("");
Line separator to use when breaking input to lines, defaults to the value of $/ at construction time.
$/
Mojo::IOLoop::LineReader inherits all methods from Mojo::IOLoop::Stream and implements the following new ones.
my $reader = Mojo::IOLoop::LineReader->new($handle);
Construct a new Mojo::IOLoop::LineReader object and subscribe to "read" in Mojo::IOLoop::Stream and "close" in Mojo::IOLoop::Stream events with special handlers.
Mojo::IOLoop::Stream, MojoX::LineStream.
Jan Henning Thorsen and Joel Berger for advice and code on #mojo.
The development of this library has been partially sponsored by Connectivity, Inc.
Adriano Ferreira <ferreira@cpan.org>
This software is copyright (c) 2017 by Adriano Ferreira.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Mojo::IOLoop::LineReader, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::IOLoop::LineReader
CPAN shell
perl -MCPAN -e shell install Mojo::IOLoop::LineReader
For more information on module installation, please visit the detailed CPAN module installation guide.