typester (owner)

Revisions

gist: 171032 Download_button fork
public
Public Clone URL: git://gist.github.com/171032.git
Embed All Files: show embed
anyevent_run.pl #
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
34
use strict;
use warnings;
use YAML;
 
use AnyEvent;
use AnyEvent::Run;
 
my $cv = AnyEvent->condvar;
 
my $w = AnyEvent::Run->new(
    cmd => sub {
        print "foo!\n";
        sleep 1;
        print "bar!\n";
        sleep 2;
        print "baz!\n";
    },
);
 
$w->on_eof(
    sub {
        warn 'on eof!';
        $cv->send;
    },
);
 
$w->on_read(sub {
    shift->push_read( line => sub {
        warn 'read: ', $_[1];
    });
});
 
$cv->recv;