views:

540

answers:

2

Hi,

I need to clear the read-only flag of a file in my Perl program that runs on Windows.

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.

Thanks,

splintor

+6  A: 

Try chmod 0777, $filename. You need the permissions in octal notation.

Ben Alpert
That missing 0 did the trick, thanks!
splintor
+4  A: 

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 0777, $filename;

This is using chmod's octal notation.

I'm using Strawberry Perl 5.8.8 on Windows Vista 64 bit.

cowgod
The difference is that you added a zero - 0777, and I used 777, which didn't work.
splintor