There's no need to clobber your STDIN
. Use IPC::Open2
or IPC::Run
to use an external program with arbitrary input/output streams.
use IPC::Open2;
# use $fd as input and $out_fd as output to external program
$pid = open2($fd, $out_fd, $opt::decompress_program);
close $fd;
while (<$out_fd>) {
...
}
(Use IPC::Open3
if you're interested in the standard error stream from the external program)