in reply to How to write to a file using CGI

You are overwriting each query with the next by using a fixed file name and opening '>'. CGI has a save() method which takes a filehandle and saves the form data in a format that CGI.pm can reload from.

sub save_form { my $self = shift; my $q = $self->query(); #lexical fh, name is argument open my $fh, '>', shift || '/path/to/output.txt' or die $!; $q->save($fh); $self->run_mode('model'); }
The use of a relative file name may be the cause of your trouble. What is the current directory when the cgi runs? Do you have permissions to write there when run by the Apache cgi_script handler?

After Compline,
Zaxo