dan61psu wrote:
> ...
> <% if(%{$Request->{Form}})
> {
> my $filename="notes.txt"
>
> if(open(ADDFILE, ">> $filename"))
> {
> print (ADDFILE $Request->Form('name') );
> close(ADDFILE);
> }
> }
> %>
>
Try something more like this:
<%
if(%{$Request->Form}) {
my $filename = 'notes.txt';
open(FILE, ">>$filename") || die("can't open file for writing: $!");
print FILE $Request->Form('name');
close FILE;
}
%>
The critical difference here is that you throw an
error that is relevant after the open command.
The system error is in $!. Always check the results
of a system call after running it, and throw a
die() if it exists. This will make it so that you
write software that really works when it seems to
instead of failing silently.
Also note that if you use >> for opening a file,
you will constantly grow that file. Using > will
clobber the file first so its reset every time.
If there is a file writing error, the web server process user id
probably does not have write priviledges to the directory
that you are trying to write to. I won't get into file
permissions now, but on unix chmod & chown are the tools
you use here: man chmod or man chown for more info.
Writing to files in /tmp/... is nice for testing because
/tmp is usually writable by everyone.
I would recommend the following books to help with
programming in Apache::ASP & mod_perl:
mod_perl - http://www.modperl.com
mod_perl cookbook - http://www.modperlcookbook.org/
learning perl - http://www.oreilly.com/catalog/lperl3/
perl cookbook - http://www.oreilly.com/catalog/cookbook/
--Josh
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks Founder Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]