Reputation: 535
I need to copy read-only files in Perl. I tried using Perl::Copy function, but it fails in case the file already exists and isn't writable.
Is there a force argument I can give to the copy function?
I want to avoid changing permissions of files, or removing the destination file before copying.
Upvotes: 2
Views: 4622
Reputation: 451
To complete the Ron answer, the Perl documentation says :
copy will not overwrite read-only files.
That's why we need to change permissions or delete file before copy.
Upvotes: 0
Reputation: 2144
with out changing permission you can't overwrite the file.in perl no function for force fully you overwrite
Upvotes: 0
Reputation: 7497
Seems like you are giving yourself unreasonable requirements. I think the best solution is to remove the destination file before copying, which should be as simple as:
unlink $dest_file if -e $dest_file;
Upvotes: 4