Version: v0.8.1 - Beta.  We welcome contributors & feedback.

File.read

$file.read($options={}) -> list|string

Description

Read the entire file and return a List of lines.

By default, it will skip over lines that are empty or have only whitespace characters.

$lines = file'files:/data.txt'.read()

foreach $lines as $line {
    // ...
}

Options

Option Value Description
keepBlanks true/false Do not filter out blank lines. (list mode only)
join true/false Return the content as a single string, including blank lines and newline characters.
$allLines = file'files:/data.txt'.read(-keepBlanks)

$fullText = file'files:/data.txt'.read(-join)

See Also