title: How do I get the PID of a process spawned with Perl's system function?
body: <p>I'm writing a Perl script (say <code>script.pl</code>) that calls another script <code>newscript.pl</code>. I want to get the PIDs of both the scripts in <code>script.pl</code> only. I can get the PID of <code>script.pl</code> by using following code </p>
  
  <pre><code>my $pid = Unix::PID-&gt;new();
  my @p = $pid-&gt;get_pidof( $pid-&gt;get_command($$), 1 );
  </code></pre>
  
  <p>After this I call <code>system</code> to execute <code>newscript.pl</code></p>
  
  <pre><code>system("perl newscript.pl");
  </code></pre>
  
  <p>I want to capture the PID generated by this <code>newscript.pl</code> in <code>script.pl</code>.</p>