title: perl - "tee" the qx operator
body: <p>I'm working on a script that currently has:</p>
  
  <pre><code>my @files = `$some_command`;
  print @files;
  chomp @files;
  foreach my $file (@files)
  {
      process($file);
  }
  </code></pre>
  
  <p>It works correctly, but the <code>some_command</code> part takes the majority of the script's time.  And during that time, nothing appears on stdout, because Perl has redirected output from <code>some_command</code> to populate the <code>@files</code> array.  It only gets printed when <code>some_command</code> is done and Perl moves on to <code>print @files;</code>.</p>
  
  <p>Is there some clever way to change this code so that the output of <code>some_command</code> appears as it is executing?  I could maybe try something like this using <code>tee(1)</code>:</p>
  
  <pre><code>my $tmpfile = File::Temp-&gt;new();
  system("$some_command | tee " . $tmpfile-&gt;filename);
  my @files;
  { local $/ = undef; @files = split /\s/, &lt;$tmpfile&gt;; }
  </code></pre>
  
  <p>But I'd rather avoid the temporary file stuff if there's a simpler solution.</p>