Не могу освоить IO:Async::.. или почему read всегдас начала
От: Spider84 Россия http://spider.vc
Дата: 01.06.10 21:33
Оценка:
Всем привет!

Пытаюсь написать на Перле скриптик
open (PINGTEST, "/bin/ping 192.168.0.1 |");
my $ping = new IO::Handle;
$ping->fdopen(fileno(PINGTEST),"r");

my $stream = IO::Async::Stream->new(
     handle  => $ping,
     autoflush => 1,
     on_read => sub {
        my ( $self, $buffref, $closed ) = @_;
        print $$buffref;
        return 0;
    }
);

$timer->start;
$loop->add( $stream );
$loop->loop_forever()


должен по задумке выводить на экран результат работы пинг.
Он и выводит только вот так:

PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.069 ms
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.069 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.054 ms
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.069 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.054 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.052 ms


Почему так?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.