>>>>> "CO" == Chas Owens <chas.ow...@gmail.com> writes:
CO> On Thu, Sep 2, 2010 at 04:39, Uri Guttman <u...@stemsystems.com> wrote: CO> snip >> if you want speed, that is not the best way to read in the file >> lines. File::Slurp (on cpan) can do that for you and is cleaner as well: CO> snip CO> If there was one thing I could change about this list, it would be CO> that to ban people from saying something is faster or slower CO> without providing the Big O Notation or a benchmark. File::Slurp CO> is written in Perl 5; there is no magical speed up from using it. CO> In fact, there is a slow down (see benchmark at the end). there is no need for O() for a beginner. and on winblows the speed gain is less for text files slurped into an array due to the line ending issues. but even slower, it is better coding than an open with no checking and then slurping with <>. CO> And that is ignoring the fact that slurping the file is a terrible CO> idea. Further ignoring the fact that we are filling (and possibly CO> overfilling) memory uselessly, we are then looping over the lines. CO> This means we must loop once to read in the file in File::Slurp, and CO> once to read each line. This is wasted time. for the excluded hash, it is simpler and probably much faster than line by line. the latter way needs to run much more perl code which is slower than a single slice. i won't benchmark it because it is also better coding which is more important. the other file could be line by line but i stuck with this paradigm for the moment. 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/