Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clear the read-only flag from a file in Perl?

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

like image 348
splintor Avatar asked Jan 15 '09 07:01

splintor


2 Answers

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

like image 182
Sophie Alpert Avatar answered Oct 20 '22 23:10

Sophie Alpert


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.

like image 41
cowgod Avatar answered Oct 21 '22 01:10

cowgod