How do you append to a file in Perl 6?
问题 I was trying this and a few other things but it truncates the file each time: 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; } } Changing this to open $file, :a also seems to truncate the file. This is 2018.04 on macOS. 回答1: Perl6 &open semantics are based on POSIX, with the following mapping: :mode<ro> --> O_RDONLY :mode<wo>