use IO::Handle; use strict; $|=1; my $io=new IO::Handle; open LOG,">> mylofile.txt" or die "mylogfile.txt: $!"; $io->fdopen(fileno(LOG),"w+") or die $!; $io->autoflush(1); my $foo=0; while(1){ $foo++; printf "Iteration: %d\n",$foo; $io->printf("Looped in %d\n",$foo); sleep 2; }