|Just another Perl shrine|
Re: Searching pattern in 400 files and getting count out of each fileby Athanasius (Prior)
|on Nov 08, 2012 at 07:21 UTC||Need Help??|
Hello Rita_G, and welcome to the Monastery!
Here is some good advice from the Camel Book (4th edition, p. 696):
Avoid unnecessary syscalls. ... Avoid unnecessary system calls. ... Worry about starting subprocesses, but only if they’re frequent.
The performance problems you are seeing almost certainly derive from the frequent use of backticks in your script. Each such use incurs an additional overhead.
The good news is that all the backtick operations in your script can be replaced with pure Perl. See grep, File::Basename, and the substitution operator s/// in Regexp Quote Like Operators and perlre.
Don’t even think about multithreading until you’ve re-implemented your script in pure Perl and benchmarked the results!
Hope that helps,
Athanasius <°(((>< contra mundum