I was doing some profiling on ack
the other night. What I found was amazing. For the simple call:
ack foo ~/big-tree-of-source
about 48% of the time was in repeated calls to File::Basename::parsefile() to figure out the extension of the file being checked. I replaced it with a simple regex and the run-time cut in half.
The slowness is undoubtedly aggravated by how the function needs to know a list of all the suffixes that it should look for. Removing the call to File::Basename::parsefile(), I also got to throw away the code that built the suffix list.