How to control timing of buffer flushing in Perl

How does exert more control on buffering in Perl? I know that I can use autoflush to flush the buffer immediately, or I can do nothing and let Perl flush when it feels like it.

But can I change the buffer size? Or can I force a flush every, say, 30 seconds?

I'd like to know how to do this for either a file handle or STDOUT. I've tried going through the IO::Handle documentation, but haven't been able to figure out what I need.

Answers


But can I change the buffer size?

Before 5.14, the size of every file handle's buffer was 4096 bytes.

Since 5.14, the size of every file handle's buffer can be chosen when Perl is built (by passing -Accflags=-DPERLIOBUF_DEFAULT_BUFSIZ=num_bytes to Configure). The default is 8192 bytes.

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

You can force a flush whenever you want to.

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

Need Your Help

Round up BigDecimal to Integer value

java math rounding bigdecimal

I have a BigDecimal which value is 450.90, I want to round up to next hole integer value, and then print the Integer value without any decimal points, like this;

How to disable https for tomcat

java tomcat https liferay

I didn't do any change but today, after turning on my computer, I'm not able to start Liferay portal...I keep getting

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.