<?xml version="1.0" encoding="windows-1252"?>
<node id="998508" title="Re: Proc::Simple store return from background process" created="2012-10-11 14:27:45" updated="2012-10-11 14:27:45">
<type id="11">
note</type>
<author id="636534">
Perlbotics</author>
<data>
<field name="doctext">
&lt;p&gt;
Short answer: You cannot with [cpan://Proc::Simple] (longer: in your case when starting a 
sub{...} as a child process)

&lt;p&gt;
 This is what happens in the child part of the [doc://fork]() that is executed for your &lt;c&gt;$func = sub{...};&lt;/c&gt;
 &lt;code&gt;
# in Proc::Simple
# $func = sub{ ... }; # your code
...
if(ref($func) eq "CODE") {
   $self-&gt;dprt("Launching code");
   $func-&gt;(@params); exit 0;            # Start perl subroutine
} else { 
...
 &lt;/code&gt;
So, the &lt;c&gt;exit 0&lt;/c&gt; (successful execution) is all that is returned from your sub{...}. 
The &lt;c&gt;$return&lt;/c&gt; value is discarded. 
&lt;p&gt;
Your sub{...} could return the result to the main process by means of [doc://perlipc|IPC] or 
by storing the result in a temporary file 
(e.g. [cpan://YAML], [cpan://JSON], [cpan://Storable], etc.). The parent process could read
the result from a pipe or load the serialised data from a file after the sub has finished.
&lt;br&gt;&lt;ins&gt;Update:&lt;/ins&gt; [cpan://IPC::Lite]

&lt;p&gt;
However, I guess, that in this particular case, you're better off with [doc://threads]
and maybe a queue.
</field>
<field name="root_node">
998484</field>
<field name="parent_node">
998484</field>
</data>
</node>
