Это выдержка из AnyEvent::Intro
# register a read watcher
my $read_watcher; $read_watcher = AnyEvent->io (
fh => $fh,
poll => "r",
cb => sub {
my $len = sysread $fh, $response, 1024, length $response;
if ($len <= 0) {
# we are done, or an error occurred, lets ignore the latter
undef $read_watcher; # no longer interested
$cv->send ($response); # send results
}
},
);
Почему используется
my $read_watcher; $read_watcher = AnyEvent->io (...
вместо
my $read_watcher = AnyEvent->io (...