open my $fh, $file or die "Can't open $file: $!"; my $content = join "", <$fh>; close $fh; # or just let it close by the next }