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

Re: using run

Thread Previous | Thread Next
From:
ToddAndMargo
Date:
June 20, 2018 16:26
Subject:
Re: using run
Message ID:
46a2f90d-ff18-6a85-d16d-74ac7ab1598b@zoho.com
On 06/20/2018 08:15 AM, Theo van den Heuvel 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?]
> 
> Thanks,
> 


Hi Theo,

I wrote a module for "run" that may be useful.  Let
me know if you want it.  It looks like this:

    ( RtnStr, RtnCode )         =    RunNoShell( "cat --number $MyDir" );
    ( RtnStr, RtnErr, RtnCode ) = RunNoShellErr( "cat --number $MyDir" );

It removes having to quote each parameter in the run string.
You just write it like you were in a command shell.  The returned
error code ($? in bash) is really handy to have (0=true,
not 0 = false in bash).

It also shows what :out and :err are all about.

-T

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