Hello Monks:
I am having problems saving some params to a file ( printing();)($file, look at the code). The funny thing is the when I run the code (>perl file.pl ) a file is created. This is what I get in the apache server error log "Cannot save file /var/www/html/datfiles/data.dat at /var/www/cgi-bin/results.pl line 48. ". Please help!
#file.pl
#!/usr/bin/perl
use strict;
use CGI::Cookie;
use CGI;
my $cgi = new CGI;
my $file = "/var/www/html/datfiles/data.dat";
print
$cgi->header( -cookie => new CGI::Cookie(-name => 'Cho
+colateChip',
-value=> $cgi-
+>param('color'),
-expires => 'T
+hu, 26-Sep-2002 00:00:00 GMT'#,
#-domain => 's
+tudents.byu.edu',
#-path => '/'
)
);
print
$cgi->start_html(-title => 'Results',
-bgcolor => $cgi->param('color'));
if ($cgi->param())
{
print
$cgi->center(
$cgi->h3("Hello: ".
$cgi->param('name')),
$cgi->p,
"The keywords are: ",join(", ",$cgi->param('words')),
$cgi->p,
"Your favorite color is: ",$cgi->param('color'));
}
printing();
print
$cgi->end_html();
sub printing
{
open(FILE, ">$file")|| die "Cannot save file $file ";
print "test";
print FILE $cgi->param('name');
print FILE join(", ",$cgi->param('words'));
print FILE $cgi->param('color');
close FILE;
}
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.