in reply to Asynchronous processes and anonymous handles
I'll add that assigning a new IO::File to $handle before calling open probably doesn't do what you'd expect:
If FILEHANDLE is an undefined scalar variable (or array or hash element) the variable is assigned a reference to a new anonymous filehandle, otherwise if FILEHANDLE is an expression, its value is used as the name of the real filehandle wanted. (This is considered a symbolic reference, so "use strict ’refs’" should not be in effect.)
So a declared $handle is all you need. It can even be written as open my $handle, "$command |".
Combining with moritz's advice,
my @handles; foreach my $f ( 0 .. 9 ) { open $handles[$f], "$command |"; }
Of course, this is assuming that you actually want to read the standard output of $command. If all you want to do is fire and forget the process, there are lighter alternatives (system).
|
|---|