title: perl background process
body: <p>I am trying to run a background process in perl. I create a child process, which is used to call another perl script. I want to run few lines of code parallely with this child process. And after the child process is done.I want to print a line of code. </p>
  
  <h3>Main script</h3>
  
  <pre><code>#!/usr/bin/perl
  
  $|=1;
  
  print "before the child process\n";
  
  my $pid = fork();
  
  if (defined $pid)
  {
      system("perl testing.pl");
  }
  
  print "before wait command\n";
  
  wait();
  
  print "after 20 secs of waiting\n";
  </code></pre>
  
  <h3>testing.pl</h3>
  
  <pre><code>#!/usr/bin/perl
  
  print "inside testing\n";
  
  sleep(20);
  </code></pre>
  
  <h3>Expected output</h3>
  
  <pre>before the child process
  before wait command
  <i>(should wait for 20 secs and then print)</i>
  after 20 secs of waiting</pre>