… | |
… | |
43 | $cv->wait; |
43 | $cv->wait; |
44 | |
44 | |
45 | =head1 DESCRIPTION |
45 | =head1 DESCRIPTION |
46 | |
46 | |
47 | This module is a helper module to make it easier to do event-based I/O on |
47 | This module is a helper module to make it easier to do event-based I/O on |
48 | filehandles (and sockets, see L<AnyEvent::Socket> for an easy way to make |
48 | filehandles. For utility functions for doing non-blocking connects and accepts |
49 | non-blocking resolves and connects). |
49 | on sockets see L<AnyEvent::Util>. |
50 | |
50 | |
51 | In the following, when the documentation refers to of "bytes" then this |
51 | In the following, when the documentation refers to of "bytes" then this |
52 | means characters. As sysread and syswrite are used for all I/O, their |
52 | means characters. As sysread and syswrite are used for all I/O, their |
53 | treatment of characters applies to this module as well. |
53 | treatment of characters applies to this module as well. |
54 | |
54 | |
… | |
… | |
531 | my $self = shift; |
531 | my $self = shift; |
532 | my $cb = pop; |
532 | my $cb = pop; |
533 | my $eol = @_ ? shift : qr|(\015?\012)|; |
533 | my $eol = @_ ? shift : qr|(\015?\012)|; |
534 | my $pos; |
534 | my $pos; |
535 | |
535 | |
536 | $eol = qr|(\Q$eol\E)| unless ref $eol; |
536 | $eol = quotemeta $eol unless ref $eol; |
537 | $eol = qr|^(.*?)($eol)|; |
537 | $eol = qr|^(.*?)($eol)|s; |
538 | |
538 | |
539 | sub { |
539 | sub { |
540 | $_[0]{rbuf} =~ s/$eol// or return; |
540 | $_[0]{rbuf} =~ s/$eol// or return; |
541 | |
541 | |
542 | $cb->($_[0], $1, $2); |
542 | $cb->($_[0], $1, $2); |