Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Created September 5, 2016 16:40
Show Gist options
  • Save dogbert17/f348e0f69bb81feed1b2802222c2e28c to your computer and use it in GitHub Desktop.
Save dogbert17/f348e0f69bb81feed1b2802222c2e28c to your computer and use it in GitHub Desktop.
=head2 method slurp-rest
multi method slurp-rest(IO::Handle:D: :$bin!, :$close --> Buf)
multi method slurp-rest(IO::Handle:D: :$enc, :$close --> Str)
Returns the remaining content of the file from the current file position
(which may have been set by previous reads or by C<seek>.) If the
adverb C<:bin> is provided a L<Buf> will be returned,
otherwise the return value will be a C<Str> with the optional encoding C<:enc>.
Specifying the adverb C<:close> will cause the filehandle to be closed when
the call has finished.
=for code :skip-test
my $fh = open("content.txt");
my $line = $fh.get;
my $rest-of-file = $fh.slurp-rest(:close);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment