use IO::Handle; # thousands of lines just for autoflush :-( #### sub autoflush{ my $old = select $_[ 0 ]; $|=1; select $old; } ... autoflush $fh;