http://www.perlmonks.org?node_id=669375


in reply to Flushing the print buffers.

I guess you got a "Name "main::OUTPUT_HANDLE" used only once: possible typo" warning with the code you posted

Try

my $old_fh = select(STDOUT); $| = 1; select($old_fh);

Generally, if you just want to turn on autoflushing on STDOUT, a simple $|=1 will do.