Wagner, David --- Senior Programmer Analyst --- CFS wrote: > I guess the bigger question is why loop thru the file multiple > times? You should be able to gather all that you need on one pass and > either move into a hash or array depending on what you need. It may be a > small file now, but if you get into the habit when a large file is > needed to be processed and you start doing mulitple reads, then you may > have problems with cpu or io increase. May be a legitimate reason, but I > would learn to get what is needed on one pass and then work with a hash > or array.
One reason: it does not fit into memory. On modern desktop machines it is difficult to image a file that won't but RAM space is still at a premium on busy servers. But even there, re-reading the file does not make sense. Every time you re-read it, you have to re-parse it. It would be better to parse it once and store the pieces in temporary files (or a database) so your program can go directly to the piece of data it wants. However, if the PHB wants it done yesterday, re-read may be the fastest way to implement it. -- Just my 0.00000002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. I like Perl; it's the only language where you can bless your thingy. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/