title: Get Output from Forked Process in Perl
body: <p>I am forking a process in Perl, actually it is a wget command. Wget writes some data to a file. I want to capture the output (not the file) which wget has generated and bring it to the main program. Here is my code snippet I am working on:</p>
  
  <pre><code>my $pid;
  my @wgetDump;
  my $videoFileName = "abc";
  my $fileURL = "http://www.youtube.com/watch?v=Y8NI2qUZ1co&amp;feature=relmfu";
  
  if ($pid = fork) {
  ####Parent Process
  print "Child Process ID: $pid";
  } else {
  ####child process
  @wgetDump = `wget -O $videoFileName -c \"$fileURL\" 2&gt;&amp;1`;
  }
  
  foreach (@wgetDump) {
  ### Here it want to get the @wgetDump Data which is actually the output of child process.
  ### But I am not getting anything here.
  }
  </code></pre>
  
  <p>Can any one please suggest.</p>