|
|
| Keep It Simple, Stupid | |
| PerlMonks |
Re: Split on new lineby McDarren (Abbot) |
| on Feb 22, 2009 at 08:16 UTC ( #745607=note: print w/ replies, xml ) | Need Help?? |
|
You have an answer to your immediate problem, but there is something else that you may wish to consider. Depending on the size of your log file, and the specs of your machine, reading the entire log file into an array may not be such a good idea. This is because memory must be allocated for the entire file. And if you happen to be dealing with a multi-gigabyte file, this may become a problem. Generally, a better approach is to read the file line by line, and process each line as you go. For this, a while loop can be used. Example: Using the above method, only one line of the file is read into memory at a time, which is much more memory-efficient. Hope this helps,
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||