<> wrote in message
news: ups.com...
> I am writing some code in which I want to copy a file to a directory
> periodically, and replace the existing file of the same name when it
> does indeed exist. Is there any way to do this with File::Copy? It
> seems to not replace if the file exists.
Your diagnosis is incorrect. File::Copy has no more trouble overwriting
an existing file than the cp system command. What is the error message
you are receiving? You *are* checking for the error message, aren't
you?
use File::Copy;
copy ('file.txt', 'otherdir/file.txt') or die "Cannot copy: $!";
As a hunch, I'd bet you don't have the needed permissions on the target
to overwrite the file.
Paul Lalli
|