File::Copy woes

F

frisina

Hi all:


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.

Help?

Thank you,

Francis
 
J

James Tolley

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.

It replaces the file for me on XP, perl 5.8.3, File::Copy 2.07
 
P

Paul Lalli

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top