Writing to STDOUT (or any other output filehandle) is buffered by default. To ask Perl to flush immediately after each write or print command, set the special variable $| to 1.
Setting this value is very helpful when you are printing to a web browser in a CGI script or writing to a socket.
Please notice that this setting does not apply to all output filehandles you may have, it only applies to the current selected output filehandle.
If you want to disable output buffering to a non selected handle, you must select it first.
#-- disable buffering to SOCKET_HANDLE, currently not selected
$previous_fh = select(SOCKET_HANDLE);
$| = 1;