Elliot Holden wrote:
okay this may seem like a simple problem but here it goes:
when running the the script below from the unix (mac osx) command line the "survey.txt" file is created and "this a test!!!" is written to the file. But when running it from a browser the file is Not created and "Browser test" is displayed in the browser.

That is a Frequently Asked Question:

perldoc -q "My CGI script runs from the command line but not the browser"


So in essennce when running from a browser the file creation section of the script is being skipped over. Please, please, please, why is this happening, somebody? I've tried it on diffferent browsers - Mozilla, IE.


open(OUTFILE, ">>survey.txt");

You should *ALWAYS* verify that the file opened correctly.

open OUTFILE, '>>', 'survey.txt' or die "Cannot open 'survey.txt' $!";


Of course it would be more useful while developing your CGI program to see the error message in the browser so add these two lines:


use CGI qw/:standard/;
use CGI::Carp 'fatalsToBrowser';


print OUTFILE "this is a test!!!\n";
close(OUTFILE);
print "<html>Browser test</html>\n";




John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to