in reply to save read-only Excel
Welcome to PerlMonks!
It's customary when asking a question here to post the snippet of code with enough context to describe the problem.
In this case, it seems as though this is more a Windows problem, as when you try to overwrite a read-only file in Windows without using Perl, you'll get the same prompt.
EDIT: Thanks Athanasius for pointing out that chmod() doesn't do what I thought it did on Windows (although it did reset the ro bit on a shared drive I was testing on). I then tried with Win32::File::SetAttributes() to no avail. However, I did finally come across a way.
# unset the RO bit on a file system("attrib -r filename.csv"); #... do writing to file # change file back to RO system("attrib +r filename.csv");
I have serious doubts if that will have any effect if it's NTFS permissions preventing writing though...
If Win32::OLE doesn't have the capability to change a file from read-only, you can use the built-in chmod() function:
chmod 0777, $file; # do stuff that writes to file
The 0777 mask will make the file read, write and executable (r, w, x) by anyone who has access to the system. 0755 will make it r/w/x the owner (which might not be you), and only readable for everyone else.
-stevieb
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: save read-only Excel
by Athanasius (Archbishop) on Jun 23, 2015 at 13:57 UTC | |
|
Re^2: save read-only Excel
by Anonymous Monk on Jun 23, 2015 at 14:42 UTC | |
|
Re^2: save read-only Excel
by ShashankSC (Initiate) on Jun 23, 2015 at 14:16 UTC | |
by davies (Monsignor) on Jun 23, 2015 at 14:40 UTC | |
by ShashankSC (Initiate) on Jun 24, 2015 at 05:48 UTC | |
by davies (Monsignor) on Jun 24, 2015 at 14:05 UTC | |
by stevieb (Canon) on Jun 23, 2015 at 14:35 UTC |