open(OLDOUT, "> &STDOUT"); my $logfile = 'MyLearn01_log.txt'; open(STDOUT, "> $logfile"); select STDOUT; <...do whatever printing to the new STDOUT...> close(STDOUT); open(STDOUT, "> &OLDOUT);