Re: $*ARGFILES and MAIN

2019-09-24 Thread Marc Chantreux
On Mon, Sep 23, 2019 at 11:34:14PM -0500, Brad Gilbert wrote: > You can create your own $*ARGFILES. > > sub MAIN ( +@ARGS ){ > my $*ARGFILES = IO::ArgFiles.new( @ARGS || $*IN ); > .say for lines; > } the way i understand https://docs.perl6.org/language/var

Re: $*ARGFILES and MAIN

2019-09-23 Thread Brad Gilbert
You can create your own $*ARGFILES. sub MAIN ( +@ARGS ){ my $*ARGFILES = IO::ArgFiles.new( @ARGS || $*IN ); .say for lines; } Note that IO::ArgFiles is now only just a subclass of IO::CatHandle. On Mon, Sep 23, 2019 at 2:51 PM Marc Chantreux wrote: > hello, > > &

Re: $*ARGFILES and MAIN

2019-09-23 Thread Marc Chantreux
tiple threads, so the `say` could be shown > out of order. wow ... thanks for pointing this. still can't mix MAIN and ARGFILES but learned. thank you very much. regards marc

Re: $*ARGFILES and MAIN

2019-09-23 Thread yary
for optional options like -H, use "multi sub main" - then you can have different sets of options available without having to fiddle with *@rest -y On Mon, Sep 23, 2019 at 2:20 PM Elizabeth Mattijsen wrote: > > On 23 Sep 2019, at 19:53, Marc Chantreux wrote: > > multi sub MAIN ( :$l ) { say

Re: $*ARGFILES and MAIN

2019-09-23 Thread Elizabeth Mattijsen
> On 23 Sep 2019, at 19:53, Marc Chantreux wrote: > multi sub MAIN ( :$l ) { say +lines } > multi sub MAIN ( :$c ) { say [+] lines>>.chars } Isn't that just `slurp.chars` ? > multi sub MAIN ( :$w ) { say [+] lines.map: +*.words } Isn't that just `+words` ? > now i want grep that can have

$*ARGFILES and MAIN

2019-09-23 Thread Marc Chantreux
hello people, short question: how to use $*ARGFILES in a MAIN function? context: as an exercice as well as demo, i reimplement unix filters (cat, grep, wc, join, paste, ...). Basic wc could be multi sub MAIN ( :$l ) { say +lines } multi sub MAIN ( :$c ) { say [+] lines>>.chars }

[perl6/specs] 658d1e: Propose change to $*ARGFILES inside MAIN

2017-07-05 Thread GitHub
ed, 05 Jul 2017) Changed paths: M v6d.pod Log Message: --- Propose change to $*ARGFILES inside MAIN Make $*ARGFILES := $*IN or IO::ArgFiles.new($*IN) inside sub MAIN

[perl6/specs] 0aa72a: Clarify a bit the $*ARGFILES in MAIN

2017-07-05 Thread GitHub
ed, 05 Jul 2017) Changed paths: M v6d.pod Log Message: --- Clarify a bit the $*ARGFILES in MAIN