You are probably right, the problem is it's quite difficult for me to strip out this piece of code out of its context, which is relatively large. Simply posting the code as-is will do no help (you could not really run it) and adapting it to a form that will be friendly for you is a tedious job (that may come out as I'm too lazy to help you help me but be sure I really appreciate all your help here!)
adapting it to a form that will be friendly for you is a tedious job
You shouldn't do it for me; you should do it for you. Unless you have a provably correct and realistically profiled single-threaded version; you'll never know if your multi-threaded version produces the correct result, or what if any benefit the threading achieved.
If it is so complex to knock up a single-threaded version of the problem, history shows that your chances of getting a multi-threaded version correct using the first approach you think of--even if you were full conversant with Perl's threading mechanisms, strengths and limitation, which I think you'll agree you are not--are slim to none.
But, 'tis your code and your call. Good luck!
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.