In article <[EMAIL PROTECTED]>, Bob Hicks wrote:
> I have the following in my pm file:
> 
> sub save_form {
>     my $self = shift;
> 
>     # Get CGI query object
>     my $q = $self->query();
>     my $record = $q->param( 'text_field' );
> 
>     open( OUTFILE, ">output.txt" ) or die "Can't open output.txt: $!";
>     print OUTFILE $record;
>     close OUTFILE;
> }
> 
> What I am trying to do is save the information that a user writes or
> changes in the textarea on a form to a file. It does not seem to work
> and from what I have looked up it should.

I've written very similar code before so I know this can work:

    my $q = $self->query;

    # Write the text area out to a file.
    open (TXT, ">output.txt") ||
        return $self->error(
            title=>'Unexpected Error',
            msg=>"Could not open file 'output.txt'.  Contact your web developer for 
assistance");

    print TXT $q->escapeHTML($q->param('desc'));
    close (TXT);

######

Note that if you are later going to redisplay this text in HTML at 
some point, you may want tou use the escapeHTML function at some point,
to avoid rendering problems.

I would try making this addition:

warn "testing record value: $record";
just before your print statement.

Then check your error log to see what value you are about to try to
print to the file.

Also, try a full path for "output.txt", or use "chdir" to move to 
directory. Perhaps the file is being created, but not in the directory
you expect.

On unix you could search for files that were recently modified:

find . -newerct '5 minutes ago' -print



        Mark







---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to