A few points if I may?
- Don't enqueue 'undef', use the 'end()' method to Thread::Queue. Much neater.
- What are you trying to accomplish with 'pos'? Because it's a race condition. You lock it and update it, but a thread may - or may not - have already dequeued and read the variable .
- You don't really need that 'eof' test, as it's implicit in reading 'FILE'. You might be better off with a while loop there.
- 'use strict' is good. 'use warnings' is good too.
I can't see why your process would be stalling though. Usually I would look for an empty queue or a lock. Can I suggest inserting:
$Q -> pending();
Into that loop, for the sake of verification. My guess is that you might be getting tripped up by that 'sleep' call. But can't tell for sure, because it seems to work ok with an 1800 line file.