See select. Open a new filehandle to the pipe, then select it; select returns the old filehandle, so, if you're absolutely sure that it will be STDOUT, just select(STDOUT) afterwards; if you want to create reusable code, try instead saving select's return value and selecting that later instead.