use IO::File; use strict; my $f = new IO::File "data", "r" or die "can not open file"; my $data; { local $/; $data = <$f>; } # at here, $data is your entire data file with embedded \n.