On 2020-08-27 13:28, Tobias Boege wrote:
On Thu, 27 Aug 2020, ToddAndMargo via perl6-users wrote:
To pick out particular lines:
$ cat Lines.txt | raku -e '.say for lines()[3,2,5]'
Line 3
Line 2
Line 5
If it is, it is buried somewhere.
And what goes inside the ()? That may seem like a dumb
remark (especially since I live and die in Top Down and
know very well what the () does) but it is a common mistake
I make with lines is forgetting the () when using the [].
How does that mistake manifest? I cannot see a way in which omitting
the sub call parentheses in code like that could possibly lead to some
different behavior.
Here is does not:
$ cat Lines.txt | raku -e '.say for lines[3,2,5]'
Line 3
Line 2
Line 5
And I am having trouble reproducing the issue. Would
help my point, no? I will write back if I find it.
Usually I forget my mistakes as soon as I figure out
the right way to do things.
Now this is getting weird!
$ cat Lines.txt | raku -ne 'my $x=$_; say $x; for $x.lines()[3,2,5] ->
$i {say $i;}'
Line 0
Nil
Nil
Nil
Line 1
Nil
Nil
Nil
Line 2
...