Skip to content
Browse files

Updated IO::Handle.slurp and added IO::Handle.spurt

  • Loading branch information...
1 parent 381e96a commit c2ac9b87beeb748f3f97def81524e1480dbbea37 @dagurval dagurval committed May 23, 2013
Showing with 31 additions and 3 deletions.
  1. +31 −3 S32-setting-library/IO.pod
34 S32-setting-library/IO.pod
@@ -269,10 +269,38 @@ C<IO::Writeable::Encoded> methods.
=item slurp
- method slurp()
+ method slurp(
+ Bool :$bin = False,
+ Str :$enc = "Unicode",
+ --> Str|Buf)
+Slurps the entire file into a C<Str> (or C<Buf> if C<:bin>) regardless of context.
+(See also C<lines>.)
+The routine will C<fail> if the file does not exist, or is a directory.
+=item spurt
+ multi method spurt (
+ Str $contents,
+ Str :$enc = $?ENC,
+ Bool :append = False,
+ Bool :$createonly = False)
+ multi method spurt (
+ Buf $contents,
+ Bool :append = False,
+ Bool :$createonly = False)
+Opens the file for writing, dumps the contents, and closes the file.
+This routine will C<fail> if the file exists and C<:createonly> is set.
+If C<:append> is provided, an existing file will not be clobbered, but the
+string will be appended.
-Reads all the remaining contents of the handle into a C<Str> (or a C<Buf>
-if the handle was opened with C<:bin>).
+The routine will also C<fail> with the corresponding exception if there was any
+other error in opening, writing, or closing.
=item t

0 comments on commit c2ac9b8

Please sign in to comment.
Something went wrong with that request. Please try again.