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

About Mr. Muskrat

user-pic I'm married with 2 girls. By day, I work as a Senior Design Engineer (full time Perl programmer) for EFJohnson Technologies, a Land Mobile Radio company, in the Dallas/Fort Worth area. By night, I play various games as the mood strikes me. (Lately it's CPAN smoke testing.)