Acme-Sort-Sleep
view release on metacpan or search on metacpan
local/lib/perl5/IO/Async/Protocol/LineStream.pm view on Meta::CPAN
CODE reference for the C<on_read_line> event.
=cut
sub _init
{
my $self = shift;
$self->SUPER::_init;
$self->{eol} = "\x0d\x0a";
$self->{eol_pattern} = qr/\x0d?\x0a/;
}
sub configure
{
my $self = shift;
my %params = @_;
foreach (qw( on_read_line )) {
$self->{$_} = delete $params{$_} if exists $params{$_};
}
$self->SUPER::configure( %params );
}
sub on_read
{
my $self = shift;
my ( $buffref, $eof ) = @_;
# Easiest to run each event individually, in case it returns a CODE ref
$$buffref =~ s/^(.*?)$self->{eol_pattern}// or return 0;
return $self->invoke_event( on_read_line => $1 ) || 1;
}
=head1 METHODS
=cut
=head2 write_line
local/lib/perl5/IO/Async/Protocol/LineStream.pm view on Meta::CPAN
Writes a line of text to the transport stream. The text will have the
end-of-line marker appended to it; C<$text> should not end with it.
=cut
sub write_line
{
my $self = shift;
my ( $line, @args ) = @_;
$self->write( "$line$self->{eol}", @args );
}
=head1 AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
=cut
0x55AA;
( run in 2.427 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )