title: Write text to pipe and read result never completes
body: <p>I've written a Perl program that opens a pipe to <code>xargs</code> so that it will read from the input and run a command with each row of input.</p>
  
  <p>I need to read the output from that pipe.</p>
  
  <p>I use <code>open3</code> and then write the input to the input file handle. Then a loop reads from the output filehandle.</p>
  
  <p>But when it prints the last line that I expect to see, it just hangs and doesn't complete the process.</p>
  
  <p>Here's an excerpt from the script</p>
  
  <pre><code>my $classNamesOutput = `classNamesInArchive $opt_archive`;
  
  my $pid = open3( \*CHILD_IN, \*CHILD_OUT, false, "xargs -n1 listJavaClassRefs -p $opt_archive -c" );
  print "pid[" . $pid . "]\n";
  
  print CHILD_IN $classNamesOutput;
  
  my $output = '';
  my $matchingArchiveNames = '';
  
  while ( my $row = &lt;CHILD_OUT&gt; ) {
      chomp $row;
      print "row[" . $row . "]\n";
  
      if ( $onlyListingMatches == 1 &amp;&amp; $row eq $opt_className ) {
          print $opt_archive;
          last;
      }
  
      if ( $onlyListingMatches == 0 ) {
          $output .= $row . "\n";
      }
  }
  
  print "Past loop.\n";
  </code></pre>
  
  <p>It never prints <code>Past loop</code>: it just hangs on the last line of output that I think the called script would have produced.</p>