Skip to content

Instantly share code, notes, and snippets.

@ryn1x
Created May 4, 2018 14:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ryn1x/18c2aa19b18b81abfff6a11766e1cc19 to your computer and use it in GitHub Desktop.
Trace Failure
# The script below runs fine with out trace, but with trace
# I get the following error:
#
# Type Block does not support associative indexing.
# in block <unit> at traceTest.p6 line 16
use trace;
sub proc(*@cmd) {
# Takes a terminal command and starts a new async process
# Returns the process, channel with stdout/stderr, and promise
my $proc = Proc::Async.new(|@cmd, :w);
my $out = Channel.new;
$proc.Supply.tap( -> $str { $out.send($str) } );
my $promise = $proc.start;
return {proc => $proc, out => $out, prom => $promise};
}
my $test = proc('echo', 'hello world');
my $output;
until $output ~~ "hello world\n" {
$output = $test{'out'}.poll;
}
say $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment