开发者

Overwrite read-only file with the Perl File::Copy function

开发者 https://www.devze.com 2023-04-10 21:21 出处:网络
I need to copy read-only files in Perl. I tried using Perl::Copy function, but it fails in case the file already exist开发者_如何学Pythons and isn\'t writable.

I need to copy read-only files in Perl. I tried using Perl::Copy function, but it fails in case the file already exist开发者_如何学Pythons 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.


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;


with out changing permission you can't overwrite the file.in perl no function for force fully you overwrite


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号