To print output to log files or screen immediately, flush the buffer:

$|=1;

http://perl.plover.com/FAQs/Buffering.html