open( $stdout , ">&STDOUT" ); open( $stderr , ">&STDERR" ); open( STDOUT , "| perl tee.pl -a $fErrorLogFile" ); select STDOUT; $| = 1; print "Some text....\n"; .. .. code .. .. select $stdout; print "Some other text....\n";