Skip to content

Instantly share code, notes, and snippets.

@tony-o
Created May 10, 2015 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony-o/06c5e6b9bf7dddb8733e to your computer and use it in GitHub Desktop.
Save tony-o/06c5e6b9bf7dddb8733e to your computer and use it in GitHub Desktop.

main

#!/usr/bin/env perl6

my $proc = Proc::Async.new(:w, "perl6", '5');
 
$proc.stdout.act(&say);
$proc.stderr.act(&warn);

my $prom = $proc.start; 
$proc.write(Buf.new(0x63,0x64,0x65)); 
#$proc.close-stdin;  #- slurp-rest only ever gets called with this line uncommented
await $prom;

sub-proc

my $data = Buf.new; 

while $data.elems == 0 { 
  $*IN.flush;
  $data = $*IN.slurp-rest(:bin);
}

$data.perl.say;
sleep 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment