Once again I find myself in a hotspot where none other than the infinitely wise Monks could offer solace...

situation is as follows:

I have a number of objects, each of which has a filehandle running in its own little separate thread. Each of those filehandles reads in data and then calls on a coderef with that data as an argument for further processing. The problem I am faced with is that due to the coderef being called from within the thread, the sub that is called on feels the other objects do not exist. So what I'm looking for is some sort of method of safely transporting the data read in from the filehandles from the individual threads to the main thread, so as to be processed in a location where all the objects actually live, allowing me to call on other objects from within the subroutine called. I've tried to use a shared array, where lines of data would be pushed on from within the separate threads, and then be shifted out in the main thread, but that wasn't really a big success.

Any ideas, suggestions, etc? Many thanks in advance.

In reply to threads question by Forsaken

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.