perl6 spurt vs file handle

Viewed 180

It seems that every time I call spurt without :append, it will open and overwrite the file and then close the file automatically. I have been writing thousands of lines to a file in a routine using spurt. Now it seems like a big waste of I/O resources. I guess if I need to write thousands of lines, I should always use "open" to get a file handle instead. Comments?

1 Answers

Yes, use open to get a file handle, and use print or say (or write for binary data) to append to it.

spurt is only useful for one-off operations, and meant to relieve you having to write open, print and close for a single logical write operation.

Related