$previous_fh = select(STDOUT); #selects STDOUT and saves the selected filehandle/handle $| = 1; #auto-flushes STDOUT select($previous_fh); # restores the previous filehandle/handle