ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Handle.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Handle.pm (file contents):
Revision 1.12 by elmex, Thu May 15 09:03:43 2008 UTC vs.
Revision 1.15 by root, Sat May 17 21:34:15 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines