|P is for Practical|
Re: Threads that return hashby BrowserUk (Pope)
|on Apr 24, 2012 at 10:55 UTC||Need Help??|
Your problem is that the return context (scalar/array/void) of the thread subroutine, is defined by the context in which that thread is created.
In your example, that means here:
Which is a scalar context. Hence, when the return is invoked here:
It is the equivalent of
And when that string is returned from the join and assigned to the hash in the calling code:
A complicated explanation, but thankfully, the solution is simple. Change the thread creation line to:
Which puts the creation of the thread into an array (list) context.
Now the code will run warnings free and produce the desired result:
Alternatively, you can mark the return context of the thread sub explicitly at creation time:
which will achieve the same result. See the section labelled "THREAD CONTEXT" in the threads pod for details.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.