title: perl how to capture STDOUT of list form system call as a filehandle
body: <p>The following prototypes demonstrate how one can capture the <code>STDOUT</code> of a "worker" script, called by the "boss" script, as a <code>FILEHANDLE</code> and turn the contents of <code>FILEHANDLE</code> into an array that one can manipulate in the "boss" script. The boss script <code>junk.pl</code>:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict; use warnings;
  my $boppin;
  my $worker = "junk2.pl";
  open(FILEHANDLE, "$worker |");
  my @scriptSTDOUT=&lt;FILEHANDLE&gt;;
  close FILEHANDLE;
  my $count=0;
  foreach my $item ( @scriptSTDOUT ) {
     $count++;
     chomp $item;
     print "$count\t$item\n";
  }
  if ( @scriptSTDOUT ) {
     $boppin = pop @scriptSTDOUT; print "boppin=$boppin\n";
  } else {
     print STDERR "nothing returned by $worker\n";
  }
  my @array = ( '. . . \x09 wow\x21' , 5 );
  system $worker, @array;
  </code></pre>
  
  <p>and the "worker" <code>junk2.pl</code>: </p>
  
  <pre><code>#!/usr/bin/perl
  use strict; use warnings; use 5.18.2;
  print "$0";
  </code></pre>
  
  <p>This use of <code>open</code> and definition of a <code>FILEHANDLE</code> is okay if the <code>$worker</code> does not require, as argument, an array whose elements contain whitespace. But if such a complex argument is required, one must call the "worker" script in list form, as at the bottom of the "boss" script. For "list form", see <a href="https://stackoverflow.com/questions/50553031/calling-a-shell-command-with-multiple-arguments">Calling a shell command with multiple arguments</a>.</p>
  
  <p>In that case, how does one capture the <code>STDOUT</code> as a <code>FILEHANDLE</code>? How can I modify the bottom line of the "boss" script to accomplish this?</p>