Perl, searching multiple files and printing returned line to new file

I am trying to find a way to utilise the full potential of my cpu cores and memory on my windows machine.

Now, I am quite familiar with grep, however, running a Unix based OS is not an option right now.

Unfortunately, the 32 bit grep for windows that I am running, I cannot run multiple instances of it or use the full potential.

Therefore I am trying to create a Perl script using Perl x64 can do the following grep:

grep -h %search_string% *.txt > retuned_Results.sl  

Now, I am having troubles with opening multiple files, one at a time and printing out the line matching the search string.

Any pointers on how I should continue would be greatly appreciated.

Thanks for your assistance.

are you still invoking grep command from your perl script? if yes, use the m operator of Perl instead.
here's a plan that could work for you:

  1. get a list of all *.txt files, using opendir and readdir
  2. open multiple threads
  3. in each thread, open a single file from the list and search the string using m operator, append the results in the output file

but this approach would work only if i/o sub-system is fast in your system. otherwise cpu and memory would wait for io if disks are slower.