Skip to content

Instantly share code, notes, and snippets.

@wakaba
Created November 16, 2012 14:56
Show Gist options
  • Save wakaba/4087929 to your computer and use it in GitHub Desktop.
Save wakaba/4087929 to your computer and use it in GitHub Desktop.
use AnyEvent::Util;
return sub {
return sub {
my $writer = $_[0]->([200, []]);
AnyEvent::Util::run_cmd(['ls'], '>' => sub {
$writer->write($_[0]) if defined $_[0];
$writer->write("Closed\n") unless defined $_[0];
})->cb(sub {
$writer->write('End');
my $timer; $timer = AE::timer(0.5, 0, sub {
$writer->close;
undef $timer;
});
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment