Documentation for routine slurp

Documentation for routine slurp, assembled from the following types:

role IO

From IO

(IO) sub slurp

Slurps the contents of the entire file into a Str (or Buf if :bin). Accepts :bin and :enc optional named parameters, with the same meaning as open(). The routine will fail if the file does not exist, or is a directory.

# read entire file as (Unicode) Str 
#my $text_contents   = slurp "path-to-file"; 
# read entire file as Latin1 Str 
#my $text_contents   = slurp "path-to-file", enc => "latin1"; 
# read entire file as Buf 
#my $binary_contents = slurp "path-to-file", :bin; 

class IO::ArgFiles

From IO::ArgFiles

(IO::ArgFiles) method slurp

Slurp the entire contents of the file into a string.

class IO::Path

From IO::Path

(IO::Path) routine slurp

multi method slurp(IO::Path:D: :$bin:$enc)

Return the file content for this path, like slurp.