相关疑难解决方法(0)

如何附加到Perl 6中的文件?

我正在尝试这个以及其他一些东西,但它每次都会截断文件:

my $file = 'primes.txt';
sub MAIN ( Int:D $low, Int:D $high where * >= $low ) {
    unless my $fh = open $file, :w, :append {
        die "Could not open '$file': {$fh.exception}";
    }

    for $low .. $high {
        $fh.put: $_ if .is-prime;
    }
}
Run Code Online (Sandbox Code Playgroud)

将此更改为open $file, :a似乎也会截断文件.这是关于macOS的2018.04.

io perl6

7
推荐指数
2
解决办法
268
查看次数

标签 统计

io ×1

perl6 ×1