Fri, 17 May 2024


How do I read an entire file as a string?

By: Nathalie, NetArt Media
Tue, 15 December 2020

my $data;
$file = "myfile.dat";
{
local $/;
open SLURP, $file or die "can't open $file: $!";
$data = <SLURP>;
close SLURP or die "cannot close $file: $!";
}


Category: Web Development
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox