http://www.perlmonks.org?node_id=711419


in reply to Re^2: split one file into many on finding a new line
in thread split one file into many on finding a new line

change this  while ( $temp_line = <INFILE> ) to this  while ( <INFILE> ) and it will work.

Also, note that if you want the filenames to be generated as MyFileName00* you'll have to drop the path from your $filename variable.