ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/eg/handle
(Generate patch)

Comparing AnyEvent/eg/handle (file contents):
Revision 1.2 by elmex, Thu May 15 08:37:55 2008 UTC vs.
Revision 1.3 by root, Sat May 24 23:34:28 2008 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
2# This small example script shows how to do non-blocking 3# This small example script shows how to do non-blocking
3# reads from a file handle. 4# reads from a file handle.
4 5
5use AnyEvent::Handle; 6use AnyEvent::Handle;
6my $cv = AnyEvent->condvar; 7my $cv = AnyEvent->condvar;
9 AnyEvent::Handle->new ( 10 AnyEvent::Handle->new (
10 fh => \*STDIN, 11 fh => \*STDIN,
11 on_eof => sub { $cv->broadcast } 12 on_eof => sub { $cv->broadcast }
12 ); 13 );
13 14
14$ae_fh->push_read_line (sub { 15$ae_fh->push_read (line => sub {
15 my ($ae_fh, $line) = @_; 16 my ($ae_fh, $line) = @_;
16 print "Got line [$line]\n"; 17 print "Got line [$line]\n";
17 18
18 $ae_fh->push_read (sub { 19 $ae_fh->push_read (sub {
19 my ($ae_fh) = @_; 20 my ($ae_fh) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines