On linux, you can see how much data is in the pipe, you might be able to sysread the first few bytes, to get the compression header, save those bytes, then redirect it( and the rest of the sysread chunks) to the appropriate decompessor pipe's filehandle. See IPC3 buffer limit problem and look at perldoc -q 'character waiting'.