Mac has asked for the wisdom of the Perl Monks concerning the following question:
I have a question, which is quicker when reading large files line by line... this one:
---OR---#!/usr/local/bin/perl open (IN, "/text.txt"); while (<IN>){ if ($_ =~ /hello/){ # do what ever } } close IN;
#!/usr/local/bin/perl open (IN, "/text.txt"); @lines = (IN); close (IN); foreach (@lines){ if ($_ =~ /hello world/){ # do what ever } }
Just wondering if the file size is > 100meg and was entirely text
Edit Masem 2001-08-20 - Edit title from "which is quicker?"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quickest way of reading in large files (while v. for)?
by CheeseLord (Deacon) on Aug 20, 2001 at 08:33 UTC | |
|
Re: which is quicker?
by maverick (Curate) on Aug 20, 2001 at 08:33 UTC | |
|
Re: Quickest way of reading in large files?
by stefp (Vicar) on Aug 20, 2001 at 23:26 UTC | |
|
Re: Quickest way of reading in large files?
by RayRay459 (Pilgrim) on Aug 20, 2001 at 20:56 UTC |