my $dat = IO::File->new($filename, 'w') or die(...); $dat->autoflush(1); print $dat ...; # Auto-flushed. $dat->print(...); # Auto-flushed. $dat->autoflush(0); print $dat ...; # Not flushed. $dat->print(...); # Not flushed. $dat->flush(); # Flushed. $dat->printflush(...); # Flushed.