Is it possible to open a pipe-based filehandle which prints to a variable in perl?
- by blackkettle
Hi,
I know I can do this,
------
open(F,"",\$var);
print F "something cool";
close(F);
print $var;
------
or this,
open(F, "| ./prog1 | ./prog2 tmp.file");
print F "something cool";
close(F);
but is it possible to combine these? The semantics of what I'd like to do should be clear from the following,
open(F,"|./prog1 | ./prog2", \$var);
print F "something cool";
close(F);
print $var;
however the above clearly won't work.
A few minutes of experimenting and googling seems to indicate that this is not possible, but I'd like to know if I'm stuck with using the `` to capture the output.