Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: File::Copy dying on Win2k when target file already there

by bart (Canon)
on Jan 16, 2003 at 20:12 UTC ( [id://227477]=note: print w/replies, xml ) Need Help??

in reply to File::Copy dying on Win2k when target file already there

Actually, it's your own script, not File::Copy, that causes the script to die:
copy($localfile, $installfile) or die "unable to copy to $installfile\n";
If you were to drop the "or die..." part, it wouldn't do that. It wouldn't replace the file that was there, either, so it's not the best of solutions.

$installfile looks like it contains an absolute path to me. You may try to delete a file without checking if it did indeed exist, like this:

unlink $installfile;
No error checking here: if it fails, nothing happens. If you were to put this line just in front of the line containing the copy(), including the die() part, this would likely do the proper thing: replace an existing file, and die() if it fails.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://227477]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-06-14 02:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.