[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] beauty vs. brains



>>>>> "JP" == Jeff Pinyan <jeffp@crusoe.net> writes:

  JP> I've often done
  JP>   $file = do { local $/, <FILE> };

  JP> when I wish to slurp a file into a scalar.  However, I recently realized
  JP> that doing

  JP>   read(FILE, $file, -s FILE);

well, you skip all the buffered I/O, resizing of the assigned buffer,
checking for EOF, etc. it would appear to be a faster idiom and i will
steal it from you. i use a simple read_file routine a lot which returns
the file in lines or whole depending on context. i will change it to use
that and speed it up. the api stays the same of course.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe