Re: a `pe4rl6 -c` error to fix

2018-06-20 Thread Brent Laabs
-c does compile time warnings, not runtime warnings.  You can't make
runtime warnings appear at compile time without using a BEGIN block.

On Wed, Jun 20, 2018 at 9:59 PM, Todd Chester  wrote:

>
>
> > On Tue, Jun 19, 2018 at 10:50 PM, Todd Chester 
> wrote:
> >> Dear Perl Developers,
> >>
> >> Would you please fix this `perl6 -c` checker error?
> >>
> >> $ perl6 -v
> >> This is Rakudo version 2018.05 built on MoarVM version 2018.05
> >> implementing Perl 6.c.
> >>
> >>
> >> The checkers passes this line with Syntax OK
> >>
> >>   $ReturnStr, $CurlStatus = CurlDownloadFile $FileAddr,
> $BaseFileName,
> >> %MaxTime<'MaxTime4'>;
> >>
> >>
> >> But actually running the line throws
> >>
> >>   Useless use of $ReturnStr in sink context
> >>
> >>
> >> The checker should throw an error if the line is "useless"
> >>
> >> Many thanks,
> >> -T
>
>
> > On 06/20/2018 11:46 AM, Will Coleda wrote:
>
>> It's a warning, not an error.
>>
>
> Indeed it is.  "-c" does warnings too and it should
> show in "-c" too.
>


Re: using run

2018-06-20 Thread Brandon Allbery
I don't manage the docs. But a ticket has already been opened:
https://github.com/perl6/doc/issues/2111

On Thu, Jun 21, 2018 at 12:59 AM Todd Chester  wrote:

>
>
> On 06/20/2018 08:58 AM, Brandon Allbery wrote:
> > A pipe is for communication with a process. "Piped to a file" means
> > what? What's the process you're communicating with?
> >
> > More to the point, "run" is intended to be lower level, specifically so
> > you can directly control things. Things like redirection and shell
> > pipelines are higher level.
>
> Hi Brandon,
>
> Make sure the documentation makes it clear that "run" is
> not running a shell and that Pipes ("|"), redirects
> ("2>&1") and such are all shell dependent.
>
> -T
>
> p.s. I almost never make a shell system call anymore.
> I prefer "run" and then manipulate the data myself the
> way I want to, not some awkward shell helper command.
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: a `pe4rl6 -c` error to fix

2018-06-20 Thread Todd Chester




> On Tue, Jun 19, 2018 at 10:50 PM, Todd Chester 
 wrote:

>> Dear Perl Developers,
>>
>> Would you please fix this `perl6 -c` checker error?
>>
>> $ perl6 -v
>> This is Rakudo version 2018.05 built on MoarVM version 2018.05
>> implementing Perl 6.c.
>>
>>
>> The checkers passes this line with Syntax OK
>>
>>   $ReturnStr, $CurlStatus = CurlDownloadFile $FileAddr, 
$BaseFileName,

>> %MaxTime<'MaxTime4'>;
>>
>>
>> But actually running the line throws
>>
>>   Useless use of $ReturnStr in sink context
>>
>>
>> The checker should throw an error if the line is "useless"
>>
>> Many thanks,
>> -T


> On 06/20/2018 11:46 AM, Will Coleda wrote:

It's a warning, not an error.


Indeed it is.  "-c" does warnings too and it should
show in "-c" too.


Re: using run

2018-06-20 Thread Todd Chester




On 06/20/2018 08:58 AM, Brandon Allbery wrote:
A pipe is for communication with a process. "Piped to a file" means 
what? What's the process you're communicating with?


More to the point, "run" is intended to be lower level, specifically so 
you can directly control things. Things like redirection and shell 
pipelines are higher level.


Hi Brandon,

Make sure the documentation makes it clear that "run" is
not running a shell and that Pipes ("|"), redirects
("2>&1") and such are all shell dependent.

-T

p.s. I almost never make a shell system call anymore.
I prefer "run" and then manipulate the data myself the
way I want to, not some awkward shell helper command.


Re: using run

2018-06-20 Thread Todd Chester




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,

There is a misunderstanding about "run".  This is running a command
with out a shell (sh, bash, csch. etc.).  Pipes "|", redirects
"2>" are all shell functions.  So, "run" can not do any of them.

But who cares!  With "run" you just suck up all the data into
a string, then you can do exactly what you want with it,
not be relying on some helper program in the shell.  Perl
is 1000 times more powerful than shell commands.

My favorite command is to suck up some data into a string, then
do a "for" on a "split" of the string and look for what I want
with match "m//" and "words" (a great grep substitute).

Once you have manipulated the data yourself in Perl a few times,
you will forget all about shell helper commands!  Way too awkward.
:-)


-T


Re: a `pe4rl6 -c` error to fix

2018-06-20 Thread Will Coleda
It's a warning, not an error.

On Tue, Jun 19, 2018 at 10:50 PM, Todd Chester  wrote:
> Dear Perl Developers,
>
> Would you please fix this `perl6 -c` checker error?
>
> $ perl6 -v
> This is Rakudo version 2018.05 built on MoarVM version 2018.05
> implementing Perl 6.c.
>
>
> The checkers passes this line with Syntax OK
>
>  $ReturnStr, $CurlStatus = CurlDownloadFile $FileAddr, $BaseFileName,
> %MaxTime<'MaxTime4'>;
>
>
> But actually running the line throws
>
>  Useless use of $ReturnStr in sink context
>
>
> The checker should throw an error if the line is "useless"
>
> Many thanks,
> -T



-- 
Will "Coke" Coleda


Re: using run

2018-06-20 Thread Theo van den Heuvel

Hi Brandon,

I used the wrong term there. I meant to say: put in a file. Sorry for 
the confusion.


Theo

Brandon Allbery schreef op 2018-06-20 17:58:

If you're going to use terms in a different way than what they
actually mean, it's going to be difficult to produce something that
does what you believe it should do *and* what it should actually do.

A pipe is for communication with a process. "Piped to a file" means
what? What's the process you're communicating with?

More to the point, "run" is intended to be lower level, specifically
so you can directly control things. Things like redirection and shell
pipelines are higher level.

That said, :out and :err are incompletely documented; the form that
tells it to create pipes so your script can communicate with the
process is there, but you can also specify handles to attach them to.
In which case you would open a file, then say :out($myHandle) to
attach the process's stdout to the handle $myHandle.




brandon s allbery kf8nh   sine nomine
associates
allber...@gmail.com
ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad
http://sinenomine.net


Re: using run

2018-06-20 Thread JJ Merelo
El mié., 20 jun. 2018 a las 17:32, Theo van den Heuvel (<
vdheu...@heuvelhlt.nl>) escribió:

> 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.
>

Posted as an issue to the documentation repo
https://github.com/perl6/doc/issues/2111

Can I set it up so that the output is piped into a file directly? If so
> how would I write that?
>

Comment or watch to be informed about the outcome. Of course, PRs are also
welcome.

JJ


Re: using run

2018-06-20 Thread ToddAndMargo

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


Re: using run

2018-06-20 Thread Brandon Allbery
If you're going to use terms in a different way than what they actually
mean, it's going to be difficult to produce something that does what you
believe it should do *and* what it should actually do.

A pipe is for communication with a process. "Piped to a file" means what?
What's the process you're communicating with?

More to the point, "run" is intended to be lower level, specifically so you
can directly control things. Things like redirection and shell pipelines
are higher level.

That said, :out and :err are incompletely documented; the form that tells
it to create pipes so your script can communicate with the process is
there, but you can also specify handles to attach them to. In which case
you would open a file, then say :out($myHandle) to attach the process's
stdout to the handle $myHandle.

On Wed, Jun 20, 2018 at 11:33 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,
>
> --
> Theo van den Heuvel
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: using run

2018-06-20 Thread Theo van den Heuvel

thanks. That helps

Jonathan Scott Duff schreef op 2018-06-20 17:50:

If you don't specify the :out adverb, then the output of the program
you are running will be sent to standard output.  Immediately when the
program executes.  If you specify the :out adverb, output from the
program will be available for capture via the $proc.out method.  A
similar thing applies for standard error.

A way to write the captured output to a file would be something like:

my $proc = run 'echo', 'foo bar baz', :out;
spurt("some-file-name", $proc.out.slurp(:close));

.slurp() will read all of the contents of the handle and return a
string (:close closes the file handle after reading everything).
spurt will write a string to a file.

hope this helps,

-Scott


Re: using run

2018-06-20 Thread Jonathan Scott Duff
If you don't specify the :out adverb, then the output of the program you
are running will be sent to standard output.  Immediately when the program
executes.  If you specify the :out adverb, output from the program will be
available for capture via the $proc.out method.  A similar thing applies
for standard error.

A way to write the captured output to a file would be something like:

my $proc = run 'echo', 'foo bar baz', :out;
spurt("some-file-name", $proc.out.slurp(:close));

.slurp() will read all of the contents of the handle and return a string
(:close closes the file handle after reading everything).
spurt will write a string to a file.

hope this helps,

-Scott


On Wed, Jun 20, 2018 at 10:33 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,
>
> --
> Theo van den Heuvel
>


using run

2018-06-20 Thread Theo van den Heuvel

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,

--
Theo van den Heuvel