/usr/share/doc/libanyevent-perl/examples/handle is in libanyevent-perl 7.010-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/usr/bin/perl
# This small example script shows how to do non-blocking
# reads from a file handle.
use AnyEvent::Handle;
my $cv = AnyEvent->condvar;
my $ae_fh =
AnyEvent::Handle->new (
fh => \*STDIN,
on_error => sub { $cv->broadcast }
);
$ae_fh->push_read (line => sub {
my ($ae_fh, $line) = @_;
print "Got line [$line]\n";
$ae_fh->push_read (sub {
my ($ae_fh) = @_;
print "Got additional data:[\n".$ae_fh->rbuf."]\n";
if ($ae_fh->rbuf =~ s/^.*\bend\b//s) {
print "'end' detected, stopping program\n";
$cv->broadcast;
return 1;
}
return 0;
});
});
$cv->wait;
|