#! perl -slw use strict; use threads; pipe \*RLOG, \*WLOG; my $oldfh = select(*WLOG); $| = 1; select($oldfh); ## pass the write handle WLOG to expect async{ ## simulate expect my $i; while( sleep 1 ) { print WLOG "output line" . ++$i; } }; open LOG, '>', 'nul' or die; ## The real logfile here ## read from the read handle RLOG, and write to the real log while( ) { print; ## Inspect the output print LOG; ## and then log it for real }