In IO::Path§
See primary documentation in context for method spurt
method spurt(IO::Path: , :, :, :)
Opens the path for writing, and writes all of the $data
into it. File will be closed afterwards. Will fail
if it cannot succeed for any reason. The $data
can be any Cool
type or any Blob
type. Arguments are as follows:
:$enc
— character encoding of the data. Takes same values as:$enc
inIO::Handle.open
. Defaults toutf8
. Ignored if$data
is aBlob
.:$append
— open the file inappend
mode, preserving existing contents, and appending data to the end of the file.:$createonly
—fail
if the file already exists.
method spurt(IO::Path:)
As of the 2020.12 release of the Rakudo compiler, it is also possible to call the spurt
method without any data. This will either create an empty file, or will truncate any existing file at the given path.
In Independent routines§
See primary documentation in context for sub spurt
multi spurt(IO() , |c)
The $path
can be any object with an IO method that returns an IO::Path
object. Calls IO::Path.spurt
on the $path
, forwarding any of the remaining arguments.
In IO::Handle§
See primary documentation in context for method spurt
multi method spurt(IO::Handle: Blob , : = False)multi method spurt(IO::Handle: Cool , : = False)
Writes all of the $data
into the filehandle, closing it when finished, if $close
is True
. For Cool
$data
, will use the encoding the handle is set to use (IO::Handle.open
or IO::Handle.encoding
).
Behavior for spurting a Cool
when the handle is in binary mode or spurting a Blob
when the handle is NOT in binary mode is undefined.