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


in reply to Re^2: Flushing the print buffers.
in thread Flushing the print buffers.

Good question.  With older Perls (pre-5.8) you could do

use IO::Handle '_IOFBF'; my $buf; # set fully buffered, with a buffer size of 1024 bytes STDOUT->setvbuf($buf, _IOFBF, 1024);

but these days, setvbuf/setbuf are no longer available unless perl is compiled to explicitly not use perlio.

I'd like to know myself whether there is a substitute for setvbuf (without writing your own XS), as on rare occasions there might be valid uses for being able to control buffering mode or buffer size with Perl. (The function doesn't seem to be POSIX, so use POSIX; wouldn't help, AFAIK...)