File::Slurp allows you read a filehandle into a scalar.
However there is another way to do this without having to load an extra module at runtime.
The select statement changes $/ (the input record separator) to a null character instead of a \n. And there you go..
open (FILE, $file) or
die "Can't open $file: $!\n";
select((select(FILE), $/ = undef));
my $contents = <FILE>;
Load file into a scalar without File::Slurp
Download Code Replies are listed 'Best First'.