Flushing Output

If a print statement is not terminated by '\n', the output is buffered. This feature can be disabled by setting the special variable $|:

$| = 1;
print "hello world"; 
sleep(2); 
print "\n";

You can also say:

use FileHandle; 
STDOUT->autoflush(1);
print "hello world";

or

use FileHandle; 
print "hello world";
STDOUT->flush();