in reply to profiling help

If your files are all of a reasonable size, upto a few 10's of megs for example-- then rather than reading each file line by line, you could probably improve the performance by slurping the whole file (see perlvar:$/).

If some or all of you files are to big to read into memory in one go, then you could try using the sliding buffer technique I posted at Re: speed up one-line "sort|uniq -c" perl code which reads the file in specifiable large chunks and takes care of ensuring that it starts each new search from a newline each time so as not to miss matches that might get split across reads. This seems to have a fairly substancial performance benefit over reading line-by-line at the cost of a little extra complexity.


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.