in reply to Trouble implementing threads

$$thr=threads->create(\&position,$text,$pattern); $$thr->join();

That looks like you're:

  1. Starting a new thread
  2. waiting for it to end
  3. Getting the result.
  4. Loop back to 1

That kind of thing is going to slow down your program with all the thread overhead. You need to create a small set of worker threads, and distribute the work between them.