Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

perl6 spurt vs file handle

Tags:

raku

spurt

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?

like image 425
lisprogtor Avatar asked Dec 29 '18 06:12

lisprogtor


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.

like image 65
moritz Avatar answered Nov 06 '22 08:11

moritz