windows 如何清除 Perl 文件中的只读标志?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/445912/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I clear the read-only flag from a file in Perl?
提问by splintor
I need to clear the read-only flag of a file in my Perl program that runs on Windows.
我需要清除在 Windows 上运行的 Perl 程序中文件的只读标志。
I know system("attrib -r $filename")
would work, but I was wondering if there is no built-in option in Perl to do it. chmod 777, $filename
doesn't seem to work.
我知道system("attrib -r $filename")
会起作用,但我想知道 Perl 中是否没有内置选项可以做到这一点。chmod 777, $filename
似乎不起作用。
Thanks,
谢谢,
splintor
夹板
回答by Sophie Alpert
Try chmod 0777, $filename
. You need the permissions in octal notation.
试试chmod 0777, $filename
。您需要八进制表示法的权限。
回答by cowgod
The most common way to handle this sort of thing is indeed with chmod
. I was able to remove the read-only flag using the following with success:
处理这类事情的最常见方法确实是使用chmod
. 我能够使用以下成功删除只读标志:
chmod 0777, $filename;
This is using chmod
's octal notation.
这是使用chmod
的八进制表示法。
I'm using Strawberry Perl 5.8.8on Windows Vista 64 bit.
我在 Windows Vista 64 位上使用Strawberry Perl 5.8.8。