in reply to Chat server impossible with Perl?

makes perl threads more similar to a toy than a tool: the impossibility to share objects, especially if they are of the filehandle kind...

With caveats--mostly surmountable--it is possible to share globs between threads. But it is a bit messy and awkward, which is why I have (mostly) avoided discussing the method publicly.

I think that this is an unecessary restriction of threads::shared that could and should be lifted. At the basic level filehandles are a per process resource and are accessible from every thread. The current restriction is artificially imposed and can be bypassed. What is required is a documented and tested mechanism for doing shared access--rather than the current situation whereby it can only be done using obscure coding tricks.

There are two things that prevent me from attempting to get the retriction lifted. The first is my lack of internals skills. The second is that whatever I develop will only be tried and tested on Win32. Without addressing these two areas, the best I could hope to do is offer suggestions for change which is a lot less likely to get anywhere than a "tested on XX and YY" patch.

All of that said, it is totally possible, and even quite easy to write a simple, complete and efficient chat server using threads. The first thing you have to do is throw away the "fork and exec" approach to the problem, and view it from the perspective of "How do I use threads to listen for new connections whilst maintaining responsiveness to existing ones".

Once you shed the shackles of preconditioned thinking, it becomes relatively easy :)

Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.