in reply to How do I read an entire file into a string?

This is conventional:
{ local $/ = undef; open FILE, "myfile" or die "Couldn't open file: $!"; binmode FILE; $string = <FILE>; close FILE; }
But if you are working with large files (or a large number of them) you might consider using File::Slurp, which, in my case, decreased the runtime of my script from 40-45 minutes to 3 minutes.

Uri Guttman (the maintainer of File-Slurp) wrote a pretty exhaustive article on slurping.

Replies are listed 'Best First'.
Re: Answer: How do I read an entire file into a string?
by Grygonos (Chaplain) on Aug 18, 2004 at 14:28 UTC
      It is worth noting that File::Slurp does NOT support binmode

      Are you sure? From the pod:

      If you set the binmode option, then the file will be slurped in binary + mode. my $bin_data = read_file( $bin_file, binmode => ':raw' ) ;