Hi folks. I use File::Copy in a backup system to copy to and from things
that are sometimes filenames and sometimes IO::Gzip filehandles.
Everything was OK until sometime in the past year or so when I started
seeing a lot of messages like
stat() on unopened filehandle GEN0 at /usr/lib/perl5/5.8.5/File/Copy.pm
line 84.
I did some investigation and found that my files were being copied just
fine. Some more investigation and I concluded that File::Copy was
calling stat() on something, which might be a file name or a filehandle
object, but ignoring the result unless it happened to be a file name, so
operating correctly. I surmise that an upgrade to perl 5.8.5 or so added a
check for stat() on an unopened filehandle as a helpful warning, and that
upgrading perl started these messages.
The warnings, while harmless, were landing in folks' email inboxes and
they were being annoyed, so I ended up putting a SIG{__WARN__} = sub{...}
and SIG{__WARN__} = undef around the copy command, just to suppress the
warning messages. This seems inelegant.
Could I have found a bug, or rather a formerly acceptable but now less so
formulation, that I found in File::Copy? I dove in and modified
File::Copy, replacing lines 82-84 with the following:
my @fs = $from_a_handle ? () : stat($from); # TEST BY ALEX
if (@fs) {
my @ts = $to_a_handle ? () : stat($to); # TEST BY ALEX
and in fact the warnings were gone.
So my question is, am I correct? And if so, can I submit a patch or
something to the maintainers of File::Copy? I wanted to ask here first,
fairly confident that if my reasoning was flawed you would spot it.
Thanks,
- Alex Aminoff
BaseSpace.net
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm