in reply to Re^2: print inside a loop
in thread print inside a loop

Can one explicitly set buffering to line- or buffer oriented, or is that chosen by the system, and all you can do is enable/disable buffering by assigning a boolean value to $|?

I guess the system choses, perhaps based on the -t flag, but I'm not sure at all.

Replies are listed 'Best First'.
Re^4: print inside a loop
by Eliya (Vicar) on Feb 22, 2011 at 13:28 UTC

    AFAIK, since the advent of PerlIO (which almost all perls are compiled/configured for these days), Perl chooses itself between block- or line-buffered, and you can only select unbuffered vs. the other two (with $|).

    In earlier versions of Perl, when stdio (C runtime lib) was used by default, you could use setvbuf (via IO::Handle) to set buffering mode and buffer size.

    These days, you usually get:

    $ perl -MIO::Handle -e 'STDOUT->setvbuf($buf, _IOLBF, 2**16)' IO::Handle::setvbuf not implemented on this architecture at -e line 1.