:out can take an argument

On Wed, Jun 20, 2018 at 10:32 AM Theo van den Heuvel
<vdheu...@heuvelhlt.nl> wrote:
>
> Hi all,
>
> trying to make sense of the documentation on run:
> https://docs.perl6.org/routine/run.
> In particular the last part. I don't  understand the adverbs :out and :
> err there.
> Can I set it up so that the output is piped into a file directly? If so
> how would I write that?
>
> I know I could use shell for that, but I doubt that is necessary.
>
> [On first reading I found the doc confusing because it start with a
> hairy example. WHy would anyone wish to write to a file named
> '>foo.txt'? How can that be the first example?]
>

    my $fh = open 'foo.txt', :w;
    run 'echo', 'foo bar baz', :out($fh);
    close $fh;

Reply via email to