develooper Front page | perl.perl6.users | Postings from June 2018

Re: using run

Thread Previous | Thread Next
From:
Brad Gilbert
Date:
June 21, 2018 17:47
Subject:
Re: using run
Message ID:
CAD2L-T3Cf-ssEQjV94SWn1VCSKAJDnXG-odjvvrXqMaQviaiGw@mail.gmail.com
:out can take an argument

On Wed, Jun 20, 2018 at 10:32 AM Theo van den Heuvel
<vdheuvel@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;

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About