I still get the same error.
I just found another case of slurp-rest which might have been the
cause but it might be good time to
look at the few other cases of "open" in my code. (And later maybe
also the code of Bailador itself.)
I tried to read more about how I am supposed to close file handles in
Perl 6, but the explanation I found didn't help me.
I opened this ticket https://github.com/perl6/doc/issues/1258 asking
for further clarification.

Anyway here is another code snippet from my code:

for open("$.source_dir/authors.txt").lines -> $line {
     ...
}

Do I need to close this myself? Can I rely on Perl closing it?

If I open a file for reading like this:

sub f {
    my $fh = open $file, :r;
    LEAVE $fh.close;

    for $fh.lines -> $line {
    }
}

Is that the correct way to put the LEAVE in? Should it be immediately
after the open statement?

And for writing?

sub write {
    my $fh = open $file, :w;
    LEAVE $fh.close;
    $fh.print("text");
}

regards
    Gabor

Reply via email to