I am writing some code that reads from a file, places the code in a form tag in my hmtl, and when I submit the form I would like to overwrite the file with data from the form. The only problem is is that I can only get a read and not a write command to work, and since my code is on a Windows box that I only have ftp access too I have no control over permissions. When I try to check the file's status with a '-w' it says that I have write permissions. Here is what I'm using:
my $filename= "$Bin/myfilename.cgi"; #filename
#open file with read access and save to array -- this works
open(TEST, "$filename") || &ErrorMessage("Can't read file");
@mycontentfromfile = <TEST>;
close(TEST);
my $guidelines = "content I would like to use to overwrite existing";
#open file with write access -- get error message listed below
open(TEST, "> $filename") || &ErrorMessage("Can't open the file to sav
+e content");
print TEST "$guidelines\n";
close(TEST );
#this print statement is executed
if (-w $filename) {
print "This file has write permissions".
}
I have tried every different type of open and the only thing that works is the read permissions. Help please.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.