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


in reply to File APPEND/OVERWRITE

You may want to look at opening the output files outside the main foreach loop. I suspect this is your problem. You are opening the same file each time you loop over @files. So the amount of entrees in the list will determine the amount of open file handles. If you must do it that way at least call close within the @files loop Also you should always check for any errors when opening a file.

i.e
open FH, "<file>" or die $!;

This simple check can give you back hours of your life ;)