I want to run a subroutine in background and return its value in my program.
So what I do is
use Proc::Simple;
$myproc = Proc::Simple->new(); # Create a new process object
$myproc->start(\&subroutine); # Launch a perl subroutine
But my subroutine return a value. I first tried using global variables, but it didn’t work.
Does anyone know how I can return a value from a bg process?
I believe the easiest way to do that is to use threads. I can run the subroutine in a thread and use join() to use its return value.