我正在尝试这个以及其他一些东西,但它每次都会截断文件:
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.