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


in reply to Can't copy file

Check if copy succeeded (File::Copy):
copy( $oldlocation, $newlocation ) or die "Copy failed: $!";

Tip #1 from the Basic debugging checklist: warnings. You try to close FH, but you opened $outfh.

Do not close the file in the foreach loop. It works as expected for me when I close it outside the loop.