blob: 843c149e41e29d873fd2fa596699fe8ef956aad5 (
plain)
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
|
#!/usr/bin/perl -w
use strict;
use AnyEvent;
use AnyEvent::Socket;
use AnyEvent::Handle;
use File::HomeDir;
my $log_socket = File::HomeDir->my_home . '/var/log.sock';
my $cv = AnyEvent->condvar;
tcp_connect 'unix/', $log_socket, sub {
my ($fh) = @_ or die "Unable to connect: $!";
my $h; $h = new AnyEvent::Handle
fh => $fh,
on_eof => sub { $h->destroy; $cv->send; },
on_error => sub { die("Connection closed."); };
while (<STDIN>) {
$h->push_write($_);
}
$h->on_drain (sub {
undef $h;
$cv->send;
});
};
$cv->recv;
|