> On 23 Sep 2019, at 19:53, Marc Chantreux <[email protected]> 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 both -H (head the line with the filename)
> and the -n (add the number of the line). my 'almost working' attempt was
> but it takes the flags as signatures.
>
> sub MAIN ( Str $pattern, :$H = False , :$n = False , *@rest ) {
> (IO::ArgFiles.new: @rest).lines>>.say
> }
You should **never** use >>. on anything that you expect the order of execution
to be the order of the input. `>>.` allows the compiler to execute the code
over multiple threads, so the `say` could be shown out of order.
Liz