in reply to Fork novice requests help...

Thor-
I actually am pondering a similar problem. The best solution that I have come up with is to place all output into a hash as a string (have each entry of output be a new record in the hash), then when all children have finished execution, and control returns to the parent thread, shoot through the hash, and output every entry on a new line. This can be cumbersome if you are recording a lot of records, unfortunately.

Hope this helps!
E-Bitch


<update>Okay, Abigail just schooled me.... I'm humbled. I Tried out my 'best solution' and as Abigail stated, I didnt quite understand threads in perl... Kudos Abigail</update>

Replies are listed 'Best First'.
Re: Fork novice requests help...
by Abigail (Deacon) on Jun 20, 2001 at 02:09 UTC
    Did you try out your "best solution"? Because I fail to see how this is supposed to work. As soon as you fork, your data (that is, your variables), are copied - that is, both the parent and the child get a copy, and they do not share the variables.

    But you mentioned threads, so, unlike the original poster, you might use threads instead of forks. Then variables can be shared. However, if two threads can access the same variable, you will need locking on the variable - which means to avoid locking, you will need to do locking.

    -- Abigail