Actually, any filehandle connected to a TTY is line buffered; this is stdio's default. If you connect STDOUT to something other than a TTY, it will be block buffered like any other filehandle. For example (on Unix, not sure what a TTY on Windows is):
perl -e "open(FH, q{>/dev/tty}); print FH (qq{a\n}); sleep(5); print F
+H (qq{a\n});"
In older versions of Perl you could get line buffering with IO::Handle's setvbuf method, but it looks like that's no longer supported.
See the stdio function isatty and perl's -t test for more information about how a TTY is detected.
|