I updated my Perl 6 slides and Masak commented on a lot of my slides. Thank You!
For example for writing to a file I had the following:
#!/usr/bin/perl6
use v6;
my $filename = "temp.txt";
my $fh = open $filename, :w;
$fh.say("hello world");
Masak: > I'd recommend $fh.close; it's more important than in Perl 5
because of the new GC.
Which brings up a question:
Can I rely in Perl 6 that a file is flushed and closed correctly when
Perl shuts down?
The probably more interesting case is this:
#!/usr/bin/perl6
use v6;
my $filename = "temp.txt";
{
my $fh = open $filename, :w;
$fh.say("hello world");
}
{
my $in = open $filename;
say $in.lines
}
Can I be sure that the file is already flushed and closed when $fh
goes out of scope
or do I need to explicitly call $fh.close in the first block?
Gabor