while(!eof(FILE) && $cur < $end) { my $buf=1024*16; read FILE, $buf, $end-$cur; $cur+=1024*16; }