my $filename = 'foo.txt'; open my $fh, '<', $filename or die; my $content; { local $/ = undef; $content = <$fh>; } # $content contains the full file content now.