I have 3 big files -- about 1 GB each. Each one is a Web server log file from a given year. I want to break them out monthly. Which do you suggest:
1. while loop through the log files, regex matching on month/year, opening a month/year filehandle if it's not open already, and writing the line out. By the end of this process, Perl will have 36 filehandles open for writing, and 1 open for reading. Will the size of the files matter? Or will having open 36 files of 100 MB each be the same as 36 files of 10 K each?
2. loop through the month/year combinations, opening only the files needed per month. At any given point, there would only be 1 file open for reading, and 1 file open for writing. However, there would be 36 loops.
3. Some other option? My amateurish experiments so far show that the process will take hours. I'm looking to remove my regex matching and replace it with index -- I suspect that's faster. Is there anything else you might offer as advice?
-Tony
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.