in reply to What the heck does $|++; do?
The 'select' statement above selects OUTPUT_HANDLE as the place to 'print' or 'write' their output and returns the name of the old file_handle that previously was recieving the printed output. You can then set the OUTPUT_HANDLE to be unbuffered and use the returned old handle to later to reset your old file handle as the receiver of output. If you wanted to do the same in a little more bizarre way you could write:$old_fh = select(OUTPUT_HANDLE); $| = 1; select($old_fh);
Alternatively you can use the IO:Handle module:select((select(STDERR), $| = 1)[0])
Or even again alternatively:use IO::Handle; OUTPUT_HANDLE->autoflush(1);
OORRR even again for linguistic nice-ness:use FileHandle; STDOUT->autoflush(1);
The above three come with an expense as the 'use'd IO::Handle module require 1000's of lines of code to be read and compiled. It may often be better to use $| directly. But there you go, you have choice!use IO::Handle; autoflush ONE_HANDLE 1; # unbuffer for clarity autoflush ANOTHER_HANDLE 0; # buffer this for speed
|
|---|