use IPC::Open2; open( TMPFILE, "<$tmpfile" ) or die "Couldn't open $tmpfile for reading: $!"; my $g_pid = open2(FROM_GUNZIP, "<&TMPFILE", "gunzip", "-c", "-d"); my $t_pid = open2(FROM_TAR, "<&FROM_GUNZIP", "tar", "tf", "-"); if( my @tar_output = ) { print "Success! The tar file contains the following:\n"; print @tar_output; } else { print "Failure!\n"; print "Either the tar file empty, or something screwed up.\n"; } if( waitpid $g_pid, 0 ) { my ($sig, $ret) = ($? & 255, $? >> 8); die "gunzip died from signal $sig" if $sig; die "gunzip exited with code $ret" if $ret; } else { die "Somebody musta reaped my gunzip process: $!"; } if( waitpid $t_pid, 0 ) { my ($sig, $ret) = ($? & 255, $? >> 8); die "tar died from signal $sig" if $sig; die "tar exited with code $ret" if $ret; } else { die "Somebody musta reaped my tar process: $!"; } END: { kill SIGKILL => $g_pid, $t_pid; } __END__