use IO::Handle; ... while (1) { print LOG "before sleep..."; LOG->flush(); sleep(1); print LOG "after sleep..."; }