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
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,
>
> &
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
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
> 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
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 }
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
ed, 05 Jul 2017)
Changed paths:
M v6d.pod
Log Message:
---
Clarify a bit the $*ARGFILES in MAIN