in reply to tty for each perl threads

Personally, I'd suggest not doing this. As soon as you start tracing/logging each thread to a different console, you loose sight of any ordering. Better to trace to a single console, serialise the access to that console and prefix your messages with the thread id.

my $semErr :shared; sub twarn { lock $semErr; my $tid = thread->tid; warn sprintf("[%3d]", $tid), @_; } ... twarn "Something happened\n";

You can then filter stderr to concentrate on individual threads.


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.
"I'd rather go naked than blow up my ass"