$old_handle = select (STDOUT); $| = 1; # perform flush after each write to STDOUT select ($old_handle); # restore previously selected handle