File::Temp and File::Copy
I recently updated File::Temp and wanted to standardize how we were creating temp files. Most places were using File::Temp already. I ran across one file where we using IO::File and returning both a file handle and the filename. I changed it to simply return a File::Temp object.
I rolled the change out to a test system and noticed a problem... All of our generated files were empty! I traced the problem down to using the File::Temp object with File::Copy's copy subroutine. I suspect it's the tied file handle bug biting us but the fix was quite simple.
Old: copy( $fh, $dest );
New: copy( "$fh", $dest );
Leave a comment