How to control buffer flush time in Perl

How to strengthen control over buffering in Perl? I know that I can use autoflush to autoflush buffer immediately, or I can’t do anything, and let Perl flush when he likes it.

But can I resize the buffer? Or can I force a flash every, say, 30 seconds?

I would like to know how to do this for a file descriptor or STDOUT. I tried looking through the IO::Handle documentation, but couldn't figure out what I needed.

+4
source share
1 answer

But is it possible to change the buffer size?

Prior to 5.14, the size of each file descriptor buffer was 4096 bytes.

Starting with 5.14, the size of each file descriptor buffer can be selected when building Perl (by passing -Accflags=-DPERLIOBUF_DEFAULT_BUFSIZ= num_bytes to Configure ). The default value is 8192 bytes.

Or can I force a flash every, say, 30 seconds?

You can force a flash whenever you want.

 use IO::Handle qw( ); # Not needed in 5.14+ $fh->flush(); STDOUT->flush(); 
+9
source

Source: https://habr.com/ru/post/1478853/


All Articles