#! /usr/bin/perl -w use strict; use IO::File; $| = 1; my $filename = "aaa.txt"; my $f = new IO::File( "> $filename" ); if( $f ) { my $n = 100; for( my $i=0; $i<$n; $i++ ) { my $str = "($i) Hello World!\n"; print( $str ); $f->print( $str ); $f->flush(); sleep( 1 ); } $f->close(); } else { print "ERROR -- Unable to open $filename\n"; } print "done!\n"; exit( 0 ); # eof