Perl Language Reading a file's content into a variable File::Slurper


This is a minimalist module that only slurps files into variables, nothing else.

use File::Slurper 'read_text';
my $contents = read_text($filename);

read_text() takes two optional parameters to specify the file encoding and whether line endings should be translated between the unixish LF or DOSish CRLF standards:

my $contents = read_text($filename, 'UTF-8', 1);