my $increment = 1000000; #For this example $$config{blocksize} == 550 my $records = int($increment / $$config{blocksize}); my $bytecnt = $$config{blocksize} * $records; #After caluclations this prints out as 999900 print "bytecnt[$bytecnt]\n"; my $file = 0; open PARENT, $$self{data} or die "Cannot open [$$self{data}] for incremental parsing\n"; while(1){ $file++; my $data = ""; if($file == 1){ read(PARENT, $data, $$config{startblock}); read(PARENT, $data, $bytecnt); open(FILE, ">tmp\\$$self{process}".sprintf("%02d", $file).".dat") or die "Cannot open tmp\\$$self{process}".sprintf("%02d", $file).".dat for incremental writing\n"; print FILE $data; close(FILE); next; } read(PARENT, $data, $bytecnt); open(FILE, ">tmp\\$$self{process}".sprintf("%02d", $file).".dat") or die "Cannot open tmp\\$$self{process}".sprintf("%02d", $file).".dat for incremental writing\n"; print FILE $data; close(FILE); if(eof(PARENT)){ last; } } close(PARENT); die;