You'll want to just pass :in and then use "$cat.in.print($input); $cat.in.close;"
We just had a thread about this on reddit with zoffix and me weighing in: https://www.reddit.com/r/perl/comments/6pwqcy/how_do_i_interact_with_a_shell_program_using_perl/ On 07/28/2017 01:49 AM, Norman Gaywood wrote: > From inside a program I'd like to send some input to the stdin of > external program and read back the stdout. > > The example in https://docs.perl6.org/language/ipc under proc comes > close to what I want: > > my $echo = run 'echo', 'Hello, world', :out; > my $cat = run 'cat', '-n', :in($echo.out), :out; > say $cat.out.get; > $cat.out.close(); > > That works, however what I want however is a single external process, > sort of like: > > my $input = q:to/EOS/; > line of text > another line > EOS > > my $cat = run 'cat', '-n', :in($input.print), :out; > my $output = $cat.out.get; > $cat.in.close; > $cat.out.close; > > say "done"; > say $output; > > But that is not correct. I seem to be missing something. >