title: How to pass a variable from a child process (fork by Parallel::ForkManager)?
body: <p>My query:</p>
  
  <p>In the following  code i had tried to bring the print <code>$commandoutput[0]</code>  to be shifted or passed into the upcoming subroutine.i tried the shift to pass it.But i failed with it.Can you please help me the right way to follow?</p>
  
  <p>Code:</p>
  
  <pre><code>my $max_forks = 4;
  
  #createThreads();
  my %commandData;
  my @arr = (
     'bhappy',  'bload -m all -l -res CPUSTEAL',
     'bqueues', 'bjobs -u all -l -hfreq 101'
  );
  
  #print @arr;
  my $fork = new Parallel::ForkManager($max_forks);
  $fork-&gt;run_on_start(
     sub {
        my $pid = shift;
     }
  );
  $fork-&gt;run_on_finish(
     sub {
        my ( $pid, $exit, $ident, $signal, $core ) = @_;
        if ($core) {
           print "PID $pid core dumped.\n";
        }
        else { }
     }
  );
  my @Commandoutput;
  my $commandposition = 0;
  for my $command (@arr) {
     $fork-&gt;start and next;
     my @var = split( " ", $command );
     $commandoutput[$commandposition] = `$command`;
     $commandposition++;
     $line = $commandoutput[0];
  
  # print $line;
     $fork-&gt;finish;
  }
  $fork-&gt;wait_all_children;
  
  #print Dumper(\%commandData);
  print $commandoutput[0];
  </code></pre>
  
  <p>Here i had tried to store the print <code>$commandoutput[0]</code> in the variable inside the subroutine.I gated here how to pass the variables from outside to inside the subroutine.</p>
  
  <pre><code>sub gen_help_data
  {
    my $lines=shift;
    print $lines;
  }
  </code></pre>