use strict; use warnings; use IPC::Open3 qw( open3 ); my $file = $ARGV[0]; open(local *TO_CHAIN, '<', $file) or die("Can't open \"$file\": $!\n"); my $gz_pid = open3('STDERR', 'gzip -dc'); my $mc_pid = open3('STDERR', 'mycommand'); while () { print; }