I don't know exactly what your code if doing, but is gen_stats is trying to read a file split_logfile is creating, you might be running into a buffering problem.
Try putting this line at the beginning of split_logfile:
local $| = 1;
This will turn autoflush on, which means Perl will output to a file immediately after a print, rathering than saving outputs up and doing them all at once.