> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/perl6-rosettacode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/r/read_entire_file.md).

# Read entire file

```perl
my $string = slurp 'sample.txt';
```

The default encoding is UTF-8. The `:enc` adverb can be used to specify a different one:

```perl
my $string = slurp 'sample.txt', :enc<UTF-16>;
```

`IO::Path` objects also provide `slurp` as a method:

```perl
my $string = 'sample.txt'.IO.slurp;
```
