File: readwrite-futures.pl

package info (click to toggle)
libio-async-perl 0.64-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,068 kB
  • ctags: 491
  • sloc: perl: 12,530; makefile: 8
file content (17 lines) | stat: -rw-r--r-- 386 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl

use strict;
use warnings;

use IO::Async::Loop;
use IO::Async::Stream;

my $loop = IO::Async::Loop->new;

$loop->add( my $stdin  = IO::Async::Stream->new_for_stdin( on_read => sub { 0 } ) );
$loop->add( my $stdout = IO::Async::Stream->new_for_stdout );

$stdout->write( sub {
   return undef if $stdin->is_read_eof;
   return $stdin->read_atmost( 64 * 1024 );
})->get;