>>>>> "R" == Ruud  <rvtol+use...@isolution.nl> writes:

  R> Thomas Bätzler wrote:
  >> my $data = do {
  >> local $/ = undef;
  >> <$fh>;
  >> };

  R> Especially for big files, that is better written as:

define big. most files are still text or similar and not big by today's
ram sizes. slurping in a megabyte is nothing today. back in the day it
would have caused major disk thrashing.

  R> my $data;
  R> { local $/;
  R>   $data = <$fh>;
  R> }

even better as:

use File::Slurp ;

my $data = read_file( $file ) ;

faster, cleaner, no need for $/ and local.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to