Skip to content

Commit 71fde8d

Browse files
author
Jan-Olof Hendig
committed
Added doc for the :close adverb in slurp-rest
1 parent 07f21bc commit 71fde8d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

doc/Type/IO/Handle.pod6

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,20 @@ Return the current position of the file pointer in bytes.
208208
209209
=head2 method slurp-rest
210210
211-
multi method slurp-rest(IO::Handle:D: :$bin! --> Buf)
212-
multi method slurp-rest(IO::Handle:D: :$enc --> Str)
211+
multi method slurp-rest(IO::Handle:D: :$bin!, :$close --> Buf)
212+
multi method slurp-rest(IO::Handle:D: :$enc, :$close --> Str)
213213
214-
Return the remaining content of the file from the current file position
214+
Returns the remaining content of the file from the current file position
215215
(which may have been set by previous reads or by C<seek>.) If the
216216
adverb C<:bin> is provided a L<Buf> will be returned,
217-
otherwise the return will be a C<Str> with the optional encoding C<:enc>.
217+
otherwise the return value will be a C<Str> with the optional encoding C<:enc>.
218+
Specifying the adverb C<:close> will cause the filehandle to be closed when
219+
the call has finished.
220+
221+
=for code :skip-test
222+
my $fh = open("content.txt");
223+
my $line = $fh.get;
224+
my $rest-of-file = $fh.slurp-rest(:close);
218225
219226
=head2 method Supply
220227

0 commit comments

Comments
 (0)