in reply to How do I get a result from a thread?
Either you need to mark the $returnn variable as shared between threads so changes are visible to other threads as well or, which is the better way in my eyes, return the result value in the code that runs inside the thread you spawn and use join() afterwards to get the result.
use strict; use warnings; use threads; my $thread = threads->create(sub { sleep 3; return "bla ble bli"; }); print "Result: ", $thead->join(), "\n";
Also take a look at the perlthrtut document.
Cheers, Flo
|
|---|