On Tue, Oct 9, 2018 at 8:31 AM Curt Tilmes <[email protected]> wrote:
>
> On Tue, Oct 9, 2018 at 9:27 AM Laurent Rosenfeld via perl6-users
> <[email protected]> wrote:
>>
>> This:
>> my $f = $fh.lines;
>> will slurp all the lines into $f (but you can still access the individual
>> items with something like $f[4]).
>
>
> Is that true? I supposed that it would hold the Seq as a scalar
> (un-iterated) Seq.
No it isn't true.
It stores the Seq in $f.
The following doesn't print anything.
my $f = 'example.txt'.IO.lines.map(*.say); Nil
(Note that I added `Nil` so that if someone tried this in the REPL, it
doesn't try to `say` what's in `$f`.)
What it does do is make the Seq marked as an item, so this only runs
one loop, and doesn't run the `.map` code.
for $f { Nil }
But both of these will:
for @$f { Nil }
for $f<> { Nil }
> I know that my @f = $fh.lines will slurp it all, but I thought you could
> avoid that by assigning it to a scalar.
>
> Curt
>